Home Explore Blog CI



neovim

29th chunk of `runtime/doc/luvref.txt`
c59fde6754c3ac74bf419fbbe2a0d226ece0b6e723c0ee010000000100000faf
 `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])`

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

                `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 operation.

                Connect to the Unix domain socket or the named pipe.

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

                Returns: `uv_connect_t userdata` 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_tty_t` — TTY handle                                  *luv-tty-handle* *uv_tty_t*

> |uv_handle_t| and |uv_stream_t| functions also apply.

TTY handles represent a stream for the console.

    >lua
    -- Simple echo program
    local stdin = uv.new_tty(0, true)
    local stdout = uv.new_tty(1, false)

    stdin:read_start(function (err, data)
      assert(not err, err)
      if data then
        stdout:write(data)
      else
        stdin:close()
        stdout:close()
      end
    end)
<

uv.new_tty({fd}, {readable})                                      *uv.new_tty()*

                Parameters:
                - `fd`: `integer`
                - `readable`: `boolean`

                Initialize a new TTY stream with the given file descriptor.
                Usually the file descriptor will be:

                 - 0 - stdin
                 - 1 - stdout
                 - 2 - stderr

                On Unix this function will determine the path of the fd of the
                terminal using ttyname_r(3), open it, and use it if the passed
                file descriptor refers to a TTY. This lets libuv put the tty
                in non-blocking mode without affecting other processes that
                share the tty.

                This function is not thread safe on systems that don’t support
                ioctl TIOCGPTN or TIOCPTYGNAME, for instance OpenBSD and
                Solaris.

                Returns: `uv_tty_t userdata` or `fail`

                Note: If reopening the TTY fails, libuv falls back to blocking
                writes.

uv.tty_set_mode({tty}, {mode})                               *uv.tty_set_mode()*

                > method form `tty:set_mode(mode)`

Title: Libuv Pipe Connection and TTY Handle Operations
Summary
This section describes `uv.pipe_connect2()`, which connects a pipe to a Unix domain socket or named pipe, supporting Linux abstract namespace sockets. It also introduces `uv_tty_t`, a TTY handle representing a stream for the console, and the associated functions `uv.new_tty()` for initializing a TTY stream with a given file descriptor, and `uv.tty_set_mode()` for setting the TTY mode.