Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions Documentation/applications/system/popen/index.rst

This file was deleted.

1 change: 1 addition & 0 deletions Documentation/os/libs/libc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ Implementation Details
:maxdepth: 1
:caption: Contents:

popen.rst
search.rst
stdbit.rst
stream.rst
Expand Down
19 changes: 19 additions & 0 deletions Documentation/os/libs/libc/popen.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
====================
popen() and dpopen()
====================

libc has ``popen()``, ``pclose()``, ``dpopen()`` and ``dpclose()`` when
``CONFIG_PIPES``, ``CONFIG_LIBC_EXECFUNCS`` and ``CONFIG_SCHED_WAITPID`` are
enabled.

``popen()`` starts ``sh -c command``. With ``CONFIG_LIBC_ENVPATH``, ``PATH``
gives the location of ``sh``; else it is ``/bin/sh``. If there is no shell,
the command is split at blanks and the program is started directly, without
shell syntax. The command starts with the ``posix_spawn()`` defaults for
priority and stack size. ``pclose()`` returns the termination status of the
shell, as from ``waitpid()``.

``dpopen()`` and ``dpclose()`` are NuttX extensions in ``unistd.h``. They
use a file descriptor instead of a stream. ``dpopen()`` with ``O_RDWR``
connects both the standard input and output of the command through a socket
pair (needs ``CONFIG_NET_LOCAL`` and ``CONFIG_NET_LOCAL_STREAM``).
6 changes: 2 additions & 4 deletions libs/libc/stdio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,11 @@ if(CONFIG_FILE_STREAM)
lib_ungetwc.c
lib_stdio_ext.c)

# popen() needs dpopen(). CONFIG_SYSTEM_POPEN selects the copy in
# apps/system/popen instead.
# popen() needs dpopen()

if(CONFIG_PIPES
AND CONFIG_LIBC_EXECFUNCS
AND CONFIG_SCHED_WAITPID
AND NOT CONFIG_SYSTEM_POPEN)
AND CONFIG_SCHED_WAITPID)
list(APPEND SRCS lib_popen.c)
endif()
endif()
Expand Down
5 changes: 1 addition & 4 deletions libs/libc/stdio/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,12 @@ CSRCS += lib_setbuffer.c lib_fputwc.c lib_putwc.c lib_fputws.c
CSRCS += lib_fopencookie.c lib_fmemopen.c lib_open_memstream.c lib_fgetwc.c
CSRCS += lib_getwc.c lib_ungetwc.c lib_stdio_ext.c

# popen() needs dpopen(). CONFIG_SYSTEM_POPEN selects the copy in
# apps/system/popen instead.
# popen() needs dpopen()

ifeq ($(CONFIG_PIPES)$(CONFIG_LIBC_EXECFUNCS)$(CONFIG_SCHED_WAITPID),yyy)
ifneq ($(CONFIG_SYSTEM_POPEN),y)
CSRCS += lib_popen.c
endif
endif
endif

# Add the stdio directory to the build

Expand Down
6 changes: 2 additions & 4 deletions libs/libc/unistd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,11 @@ if(CONFIG_PIPES)
list(APPEND SRCS lib_pipe.c)
endif()

# dpopen() needs pipes, posix_spawn() and waitpid(). CONFIG_SYSTEM_POPEN
# selects the copy in apps/system/popen instead.
# dpopen() needs pipes, posix_spawn() and waitpid()

if(CONFIG_PIPES
AND CONFIG_LIBC_EXECFUNCS
AND CONFIG_SCHED_WAITPID
AND NOT CONFIG_SYSTEM_POPEN)
AND CONFIG_SCHED_WAITPID)
list(APPEND SRCS lib_dpopen.c)
endif()

Expand Down
5 changes: 1 addition & 4 deletions libs/libc/unistd/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,11 @@ ifeq ($(CONFIG_PIPES),y)
CSRCS += lib_pipe.c
endif

# dpopen() needs pipes, posix_spawn() and waitpid(). CONFIG_SYSTEM_POPEN
# selects the copy in apps/system/popen instead.
# dpopen() needs pipes, posix_spawn() and waitpid()

ifeq ($(CONFIG_PIPES)$(CONFIG_LIBC_EXECFUNCS)$(CONFIG_SCHED_WAITPID),yyy)
ifneq ($(CONFIG_SYSTEM_POPEN),y)
CSRCS += lib_dpopen.c
endif
endif

# Add the unistd directory to the build

Expand Down
Loading