summaryrefslogtreecommitdiffstats
path: root/man2/pipe.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/pipe.2')
-rw-r--r--man2/pipe.245
1 files changed, 25 insertions, 20 deletions
diff --git a/man2/pipe.2 b/man2/pipe.2
index 400406b41..d8142f926 100644
--- a/man2/pipe.2
+++ b/man2/pipe.2
@@ -13,7 +13,7 @@
.\" to EXAMPLE text.
.\" 2008-10-10, mtk: add description of pipe2()
.\"
-.TH pipe 2 2023-02-05 "Linux man-pages 6.03"
+.TH pipe 2 2023-07-30 "Linux man-pages 6.05.01"
.SH NAME
pipe, pipe2 \- create pipe
.SH LIBRARY
@@ -32,7 +32,7 @@ Standard C library
.BI "int pipe2(int " pipefd "[2], int " flags );
.PP
/* On Alpha, IA-64, MIPS, SuperH, and SPARC/SPARC64, pipe() has the
- following prototype; see NOTES */
+ following prototype; see VERSIONS */
.PP
.B #include <unistd.h>
.PP
@@ -193,16 +193,6 @@ and support for notifications
.RB ( CONFIG_WATCH_QUEUE )
is not compiled into the kernel.
.SH VERSIONS
-.BR pipe2 ()
-was added in Linux 2.6.27;
-glibc support is available starting with glibc 2.9.
-.SH STANDARDS
-.BR pipe ():
-POSIX.1-2001, POSIX.1-2008.
-.PP
-.BR pipe2 ()
-is Linux-specific.
-.SH NOTES
.\" See http://math-atlas.sourceforge.net/devel/assembly/64.psabi.1.33.ps.Z
.\" for example, section 3.2.1 "Registers and the Stack Frame".
The System V ABI on some architectures allows the use of more than one register
@@ -219,6 +209,21 @@ wrapper function transparently deals with this.
See
.BR syscall (2)
for information regarding registers used for storing second file descriptor.
+.SH STANDARDS
+.TP
+.BR pipe ()
+POSIX.1-2008.
+.TP
+.BR pipe2 ()
+Linux.
+.SH HISTORY
+.TP
+.BR pipe ()
+POSIX.1-2001.
+.TP
+.BR pipe2 ()
+Linux 2.6.27,
+glibc 2.9.
.SH EXAMPLES
.\" fork.2 refers to this example program.
The following program creates a pipe, and then
@@ -243,40 +248,40 @@ and echoes it on standard output.
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
-
+\&
int
main(int argc, char *argv[])
{
int pipefd[2];
char buf;
pid_t cpid;
-
+\&
if (argc != 2) {
fprintf(stderr, "Usage: %s <string>\en", argv[0]);
exit(EXIT_FAILURE);
}
-
+\&
if (pipe(pipefd) == \-1) {
perror("pipe");
exit(EXIT_FAILURE);
}
-
+\&
cpid = fork();
if (cpid == \-1) {
perror("fork");
exit(EXIT_FAILURE);
}
-
+\&
if (cpid == 0) { /* Child reads from pipe */
close(pipefd[1]); /* Close unused write end */
-
+\&
while (read(pipefd[0], &buf, 1) > 0)
write(STDOUT_FILENO, &buf, 1);
-
+\&
write(STDOUT_FILENO, "\en", 1);
close(pipefd[0]);
_exit(EXIT_SUCCESS);
-
+\&
} else { /* Parent writes argv[1] to pipe */
close(pipefd[0]); /* Close unused read end */
write(pipefd[1], argv[1], strlen(argv[1]));