Function

GLib-2.0GLibunix_open_pipeSince 2.30

  • 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().

    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_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).

    2.30