Similar to the UNIX pipe() call, but on modern systems like Linux
uses the pipe2() system call, which atomically creates a pipe with
the configured flags.
As of GLib 2.78, the supported flags are O_CLOEXEC/FD_CLOEXEC (see below)
and O_NONBLOCK. Prior to GLib 2.78, only FD_CLOEXEC was supported — if
you wanted to configure O_NONBLOCK then that had to be done separately with
fcntl().
It is a programmer error to call this function with unsupported flags, and a
critical warning will be raised.
As of GLib 2.78, it is preferred to pass O_CLOEXEC in, rather than
FD_CLOEXEC, as that matches the underlying pipe() API more closely. Prior
to 2.78, only FD_CLOEXEC was supported. Support for FD_CLOEXEC may be
deprecated and removed in future.
Parameters
fds: number[]
Array of two integers
flags: number
Bitfield of file descriptor flags, as for fcntl()
Returns boolean
true on success, false if not (and errno will be set).
Similar to the UNIX
pipe()call, but on modern systems like Linux uses thepipe2()system call, which atomically creates a pipe with the configured flags.As of GLib 2.78, the supported flags are
O_CLOEXEC/FD_CLOEXEC(see below) andO_NONBLOCK. Prior to GLib 2.78, onlyFD_CLOEXECwas supported — if you wanted to configureO_NONBLOCKthen that had to be done separately withfcntl().Since GLib 2.80, the constants GLib.UnixPipeEnd.READ and GLib.UnixPipeEnd.WRITE can be used as mnemonic indexes in
fds.It is a programmer error to call this function with unsupported flags, and a critical warning will be raised.
As of GLib 2.78, it is preferred to pass
O_CLOEXECin, rather thanFD_CLOEXEC, as that matches the underlyingpipe()API more closely. Prior to 2.78, onlyFD_CLOEXECwas supported. Support forFD_CLOEXECmay be deprecated and removed in future.