summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/popen.3
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gen/popen.3')
-rw-r--r--lib/libc/gen/popen.354
1 files changed, 21 insertions, 33 deletions
diff --git a/lib/libc/gen/popen.3 b/lib/libc/gen/popen.3
index 9ca1bb3..01b0c2f 100644
--- a/lib/libc/gen/popen.3
+++ b/lib/libc/gen/popen.3
@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)popen.3 8.2 (Berkeley) 5/3/95
+.\" @(#)popen.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd May 3, 1995
+.Dd June 4, 1993
.Dt POPEN 3
.Os
.Sh NAME
@@ -50,32 +50,13 @@ The
.Fn popen
function
.Dq opens
-a process by creating an IPC connection,
+a process by creating a pipe,
forking,
and invoking the shell.
-Historically,
-.Nm popen
-was implemented with a unidirectional pipe;
-hence many implementations of
-.Nm popen
-only allow the
+Since a pipe is by definition unidirectional, the
.Fa type
-argument to specify reading or writing, not both.
-Since
-.Nm popen
-is now implemented using sockets, the
-.Fa type
-may request a bidirectional data flow.
-The
-.Fa type
-argument is a pointer to a null-terminated string
-which must be
-.Ql r
-for reading,
-.Ql w
-for writing, or
-.Ql r+
-for reading and writing.
+argument may specify only reading or writing, not both;
+the resulting stream is correspondingly read-only or write-only.
.Pp
The
.Fa command
@@ -86,6 +67,15 @@ This command is passed to
using the
.Fl c
flag; interpretation, if any, is performed by the shell.
+The
+.Fa mode
+argument is a pointer to a null-terminated string
+which must be either
+.Ql r
+for reading
+or
+.Ql w
+for writing.
.Pp
The return value from
.Fn popen
@@ -123,10 +113,9 @@ The
function returns
.Dv NULL
if the
-.Xr fork 2 ,
-.Xr pipe 2 ,
+.Xr fork 2
or
-.Xr socketpair 2
+.Xr pipe 2
calls fail,
or if it cannot allocate memory.
.Pp
@@ -150,13 +139,12 @@ The
function does not reliably set
.Va errno .
.Sh SEE ALSO
-.Xr fork 2 ,
.Xr sh 1 ,
+.Xr fork 2 ,
.Xr pipe 2 ,
-.Xr socketpair 2 ,
.Xr wait4 2 ,
-.Xr fflush 3 ,
.Xr fclose 3 ,
+.Xr fflush 3 ,
.Xr fopen 3 ,
.Xr stdio 3 ,
.Xr system 3
@@ -182,9 +170,9 @@ The
.Fn popen
argument
always calls
-.Xr sh ,
+.Xr sh 1 ,
never calls
-.Xr csh .
+.Xr csh 1 .
.Sh HISTORY
A
.Fn popen
OpenPOWER on IntegriCloud