Home Explore Blog CI



neovim

28th chunk of `runtime/doc/luvref.txt`
673f57216866d58bf575368885a41696b81276bcf110d73e0000000100000fa8
 Used to receive handles over IPC pipes.

                First - call |uv.pipe_pending_count()|, if it's > 0 then
                initialize a handle of the given type, returned by
                `uv.pipe_pending_type()` and call `uv.accept(pipe, handle)` .

                Returns: `string`

uv.pipe_chmod({pipe}, {flags})                                 *uv.pipe_chmod()*

                > method form `pipe:chmod(flags)`

                Parameters:
                - `pipe`: `uv_pipe_t userdata`
                - `flags`: `string`

                Alters pipe permissions, allowing it to be accessed from
                processes run by different users. Makes the pipe writable or
                readable by all users. `flags` are: `"r"`, `"w"`, `"rw"`, or
                `"wr"` where `r` is `READABLE` and `w` is `WRITABLE`. This
                function is blocking.

                Returns: `0` or `fail`

uv.pipe({read_flags}, {write_flags})                                 *uv.pipe()*

                Parameters:
                - `read_flags`: `table` or `nil`
                  - `nonblock`: `boolean` (default: `false`)
                - `write_flags`: `table` or `nil`
                  - `nonblock`: `boolean` (default: `false`)

                Create a pair of connected pipe handles. Data may be written
                to the `write` fd and read from the `read` fd. The resulting
                handles can be passed to `pipe_open`, used with `spawn`, or
                for any other purpose.

                Flags:
                 - `nonblock`: Opens the specified socket handle for
                   `OVERLAPPED` or `FIONBIO`/`O_NONBLOCK` I/O usage. This is
                   recommended for handles that will be used by libuv, and not
                   usually recommended otherwise.

                Equivalent to `pipe(2)` with the `O_CLOEXEC` flag set.

                Returns: `table` or `fail`
                - `read` : `integer` (file descriptor)
                - `write` : `integer` (file descriptor)

                    >lua
                    -- Simple read/write with pipe_open
                    local fds = uv.pipe({nonblock=true}, {nonblock=true})

                    local read_pipe = uv.new_pipe()
                    read_pipe:open(fds.read)

                    local write_pipe = uv.new_pipe()
                    write_pipe:open(fds.write)

                    write_pipe:write("hello")
                    read_pipe:read_start(function(err, chunk)
                      assert(not err, err)
                      print(chunk)
                    end)
<

uv.pipe_bind2({pipe}, {name}, {flags})                         *uv.pipe_bind2()*

                > method form `pipe:pipe_bind(name, flags)`

                Parameters:
                - `pipe`: `uv_pipe_t userdata`
                - `name`: `string`
                - `flags`: `integer` or `table` or `nil` (default: 0)

                Flags:
                 - If `type(flags)` is `number`, it must be `0` or
                   `uv.constants.PIPE_NO_TRUNCATE`.
                 - If `type(flags)` is `table`, it must be `{}` or
                   `{ no_truncate = true|false }`.
                 - If `type(flags)` is `nil`, it use default value `0`.
                 - Returns `EINVAL` for unsupported flags without performing the
                   bind.

                Bind the pipe to a file path (Unix) or a name (Windows).

                Supports Linux abstract namespace sockets. namelen must include
                the leading '\0' byte but not the trailing nul byte.

                Returns: `0` or `fail`

                *Note*:
                1. Paths on Unix get truncated to sizeof(sockaddr_un.sun_path)
                   bytes, typically between 92 and 108 bytes.
                2. New in version 1.46.0.

uv.pipe_connect2(pipe, name, [flags], [callback])           *uv.pipe_connect2()*

                > method form `pipe:connect2(name, [flags], [callback])`

Title: Libuv Pipe Operations: Handle Receiving, Permission Modification, and Creation
Summary
This section covers the `uv.pipe_pending_type()` function used to receive handles over IPC pipes, the `uv.pipe_chmod()` function for altering pipe permissions for cross-user access, and the `uv.pipe()` function for creating connected pipe handle pairs with non-blocking flag options. It also describes `uv.pipe_bind2()`, a new (v1.46.0) function similar to `uv.pipe_bind` with enhanced flag support for Linux abstract namespace sockets.