1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-29 06:20:30 +02:00

'pipe' now takes an optional 'flags' parameter.

This is the same strategy as used for the 'accept4' bindings introduced
in 6e0965104c.

* 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.
This commit is contained in:
Ludovic Courtès 2022-09-19 22:27:10 +02:00
parent 9592516bfa
commit 1d313bf5f0
6 changed files with 110 additions and 9 deletions

View file

@ -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