summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-09-19 22:27:10 +0200
committerLudovic Courtès <ludo@gnu.org>2022-09-19 22:30:16 +0200
commit1d313bf5f0d296d766bd3a0e6d030df37c71711b (patch)
tree1d7e8e73903e842725da9306c59e5d3cc4542491 /doc
parent9592516bfa23056542e9b05b00a4449d0809c6bc (diff)
downloadguile-1d313bf5f0d296d766bd3a0e6d030df37c71711b.tar.gz
'pipe' now takes an optional 'flags' parameter.
This is the same strategy as used for the 'accept4' bindings introduced in 6e0965104c579431e5a786b60e1a964a112c73b8. * libguile/posix.c (scm_pipe): Rename to... (scm_pipe2): ... this. Add an optional 'flags' parameter and honor it. (scm_pipe): Rewrite as a call to 'scm_pipe2'. * libguile/posix.h (scm_pipe2): New declaration. * test-suite/tests/posix.test ("pipe"): New tests. * configure.ac: Look for 'pipe2'. * NEWS: Update.
Diffstat (limited to 'doc')
-rw-r--r--doc/ref/posix.texi20
1 files changed, 19 insertions, 1 deletions
diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index 19911a427..6a9f54102 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -318,7 +318,7 @@ the file descriptor will be closed even if a port is using it. The
return value is unspecified.
@end deffn
-@deffn {Scheme Procedure} pipe
+@deffn {Scheme Procedure} pipe [flags]
@deffnx {C Function} scm_pipe ()
@cindex pipe
Return a newly created pipe: a pair of ports which are linked together
@@ -329,6 +329,24 @@ for communication with a newly forked child process. The need to flush
the output port can be avoided by making it unbuffered using
@code{setvbuf} (@pxref{Buffering}).
+Optionally, on systems that support it such as GNU/Linux and
+GNU/Hurd, @var{flags} can specify a bitwise-or of the following
+constants:
+
+@table @code
+@item O_CLOEXEC
+Mark the returned file descriptors as close-on-exec;
+@item O_DIRECT
+Create a pipe that performs input/output in ``packet"
+mode---see @command{man 2 pipe} for details;
+@item O_NONBLOCK
+Set the @code{O_NONBLOCK} status flag (non-blocking input and
+output) on the file descriptors.
+@end table
+
+On systems that do @emph{not} support it, passing a non-zero
+@var{flags} value triggers a @code{system-error} exception.
+
@defvar PIPE_BUF
A write of up to @code{PIPE_BUF} many bytes to a pipe is atomic,
meaning when done it goes into the pipe instantaneously and as a