Nvim :help
pages, generated
from source
using the tree-sitter-vimdoc parser.
vim.uv.version()
).uv
module, but can
be used in other Lua environments.local uv = vim.uv
local server = uv.new_tcp()
server:bind("127.0.0.1", 1337)
server:listen(128, function (err)
assert(not err, err)
local client = uv.new_tcp()
server:accept(client)
client:read_start(function (err, chunk)
assert(not err, err)
if chunk then
client:write(chunk)
else
client:shutdown()
client:close()
end
end)
end)
print("TCP server listening at 127.0.0.1 port 1337")
uv.run() -- an explicit run call is necessary outside of luvit
uv
for
simplicity. This module consists mostly of functions with names corresponding
to their original libuv versions. For example, the libuv function
uv_tcp_bind
has a luv version at uv.tcp_bind(). Currently, only two
non-function fields exists: uv.constants
and uv.errno
, which are tables.uv.tcp_bind(server, host, port)
can alternatively be
called as server:bind(host, port)
. Note that the first argument server
becomes the object and tcp_
is removed from the function name. Method forms
are documented below where they exist.callable
: a function
; or a table
or userdata
with a __call
metamethod
buffer
: a string
or a sequential table
of string
s
threadargs
: variable arguments (...
) of type nil
, boolean
, number
,
string
, or userdata
; number of arguments limited to 9.
uv.errno
, the functions used to handle them are not
exposed to luv users. Instead, if an internal error is encountered, the luv
function will return to the caller an assertable nil, err, name
tuple.nil
idiomatically indicates failure
err
is a string with the format {name}: {message}
{name}
is the error name provided internally by uv_err_name
{message}
is a human-readable message provided internally by
uv_strerror
name
is the same string used to construct err
fail
pseudo-type.0
to indicate
success, or sometimes nothing at all. These cases are documented below.UV_
prefix) and its value is a negative number.
See Libuv's "Error constants" page for further details.
(https://docs.libuv.org/en/v1.x/errors.html#error-constants)E2BIG
: argument list too long.
EACCES
: permission denied.
EADDRINUSE
: address already in use.
EADDRNOTAVAIL
: address not available.
EAFNOSUPPORT
: address family not supported.
EAGAIN
: resource temporarily unavailable.
EAI_ADDRFAMILY
: address family not supported.
EAI_AGAIN
: temporary failure.
EAI_BADFLAGS
: bad ai_flags value.
EAI_BADHINTS
: invalid value for hints.
EAI_CANCELED
: request canceled.
EAI_FAIL
: permanent failure.
EAI_FAMILY
: ai_family not supported.
EAI_MEMORY
: out of memory.
EAI_NODATA
: no address.
EAI_NONAME
: unknown node or service.
EAI_OVERFLOW
: argument buffer overflow.
EAI_PROTOCOL
: resolved protocol is unknown.
EAI_SERVICE
: service not available for socket type.
EAI_SOCKTYPE
: socket type not supported.
EALREADY
: connection already in progress.
EBADF
: bad file descriptor.
EBUSY
: resource busy or locked.
ECANCELED
: operation canceled.
ECHARSET
: invalid Unicode character.
ECONNABORTED
: software caused connection abort.
ECONNREFUSED
: connection refused.
ECONNRESET
: connection reset by peer.
EDESTADDRREQ
: destination address required.
EEXIST
: file already exists.
EFAULT
: bad address in system call argument.
EFBIG
: file too large.
EHOSTUNREACH
: host is unreachable.
EINTR
: interrupted system call.
EINVAL
: invalid argument.
EIO
: i/o error.
EISCONN
: socket is already connected.
EISDIR
: illegal operation on a directory.
ELOOP
: too many symbolic links encountered.
EMFILE
: too many open files.
EMSGSIZE
: message too long.
ENAMETOOLONG
: name too long.
ENETDOWN
: network is down.
ENETUNREACH
: network is unreachable.
ENFILE
: file table overflow.
ENOBUFS
: no buffer space available.
ENODEV
: no such device.
ENOENT
: no such file or directory.
ENOMEM
: not enough memory.
ENONET
: machine is not on the network.
ENOPROTOOPT
: protocol not available.
ENOSPC
: no space left on device.
ENOSYS
: function not implemented.
ENOTCONN
: socket is not connected.
ENOTDIR
: not a directory.
ENOTEMPTY
: directory not empty.
ENOTSOCK
: socket operation on non-socket.
ENOTSUP
: operation not supported on socket.
EOVERFLOW
: value too large for defined data type.
EPERM
: operation not permitted.
EPIPE
: broken pipe.
EPROTO
: protocol error.
EPROTONOSUPPORT
: protocol not supported.
EPROTOTYPE
: protocol wrong type for socket.
ERANGE
: result too large.
EROFS
: read-only file system.
ESHUTDOWN
: cannot send after transport endpoint shutdown.
ESPIPE
: invalid seek.
ESRCH
: no such process.
ETIMEDOUT
: connection timed out.
ETXTBSY
: text file is busy.
EXDEV
: cross-device link not permitted.
UNKNOWN
: unknown error.
EOF
: end of file.
ENXIO
: no such device or address.
EMLINK
: too many links.
ENOTTY
: inappropriate ioctl for device.
EFTYPE
: inappropriate file type or format.
EILSEQ
: illegal byte sequence.
ESOCKTNOSUPPORT
: socket type not supported.
integer
string
uv_loop_t
— Event looploop_close()
. Call this function only after the loop has
finished executing and all open handles and requests have been
closed, or it will return EBUSY
.0
or fail
mode
: string
or nil
(default: "default"
)
"default"
: Runs the event loop until there are no more
active and referenced handles or requests. Returns true
if uv.stop() was called and there are still active
handles or requests. Returns false
in all other cases.
"once"
: Poll for I/O once. Note that this function
blocks if there are no pending callbacks. Returns false
when done (no active handles or requests left), or true
if more callbacks are expected (meaning you should run the
event loop again sometime in the future).
"nowait"
: Poll for I/O once but don't block if there are
no pending callbacks. Returns false
if done (no active
handles or requests left), or true
if more callbacks are
expected (meaning you should run the event loop again
sometime in the future).
boolean
or fail
uv.run()
after loading user
code, but if you use the luv bindings directly, you need to
call this after registering your initial set of event
callbacks to start the event loop.option
: string
...
: depends on option
, see below
"block_signal"
: Block a signal when polling for new
events. The second argument to loop_configure() is the
signal name (as a lowercase string) or the signal number.
This operation is currently only implemented for
"sigprof"
signals, to suppress unnecessary wakeups when
using a sampling profiler. Requesting other signals will
fail with EINVAL
.
"metrics_idle_time"
: Accumulate the amount of idle time
the event loop spends in the event provider. This option
is necessary to use metrics_idle_time()
.
uv.loop_configure("block_signal", "sigprof")
0
or fail
ENOSYS
error; it means the
loop option is not supported by the platform.nil
is returned instead.string
or nil
true
if there are referenced active handles, active
requests, or closing handles in the loop; otherwise, false
.boolean
or fail
uv.run("nowait")
to
poll in one thread and run the event loop's callbacks in
anotherinteger
or nil
integer
integer
callback
: callable
callback
will be executed with
each handle.-- Example usage of uv.walk to close all handles that
-- aren't already closing.
uv.walk(function (handle)
if not handle:is_closing() then
handle:close()
end
end)
uv_req_t
— Base requestuv_req_t
is the base type for all libuv request types.req:cancel()
uv_getaddrinfo_t
, uv_getnameinfo_t
and uv_work_t
requests is currently supported.0
or fail
req:get_type()
"fs"
for uv_fs_t) and the libuv enum integer for the
request's type (uv_req_type
).string, integer
uv_handle_t
— Base handleuv_handle_t
is the base type for all libuv handle types. All API functions
defined here work with any handle type.handle:is_active()
true
if the handle is active, false
if it's
inactive. What "active” means depends on the type of handle:boolean
or fail
handle:is_closing()
true
if the handle is closing or closed, false
otherwise.boolean
or fail
handle:close([callback])
callback
: callable
or nil
callback
will be called
asynchronously after this call. This MUST be called on each
handle before memory is released.callback
will still be deferred to the next iteration of the
event loop. It gives you a chance to free up any resources
associated with the handle.uv_connect_t
or uv_write_t
, are
cancelled and have their callbacks called asynchronously with
ECANCELED
.handle:ref()
handle:unref()
handle:has_ref()
true
if the handle referenced, false
if not.boolean
or fail
handle:send_buffer_size([size])
size
: integer
or nil
(default: 0
)
size
is omitted (or 0
), this will return the current
send buffer size; otherwise, this will use size
to set the
new send buffer size.integer
or fail
(if size
is nil
or 0
)
0
or fail
(if size
is not nil
and not 0
)
handle:recv_buffer_size([size])
size
: integer
or nil
(default: 0
)
size
is omitted (or 0
), this will return the current
send buffer size; otherwise, this will use size
to set the
new send buffer size.integer
or fail
(if size
is nil
or 0
)
0
or fail
(if size
is not nil
and not 0
)
handle:fileno()
EINVAL
.EBADF
.integer
or fail
handle:get_type()
"pipe"
for uv_pipe_t) and the libuv enum integer for the
handle's type (uv_handle_type
).string, integer
uv_timer_t
— Timer handleuv_timer_t userdata
or fail
-- Creating a simple setTimeout wrapper
local function setTimeout(timeout, callback)
local timer = uv.new_timer()
timer:start(timeout, 0, function ()
timer:stop()
timer:close()
callback()
end)
return timer
end
-- Creating a simple setInterval wrapper
local function setInterval(interval, callback)
local timer = uv.new_timer()
timer:start(interval, interval, function ()
callback()
end)
return timer
end
-- And clearInterval
local function clearInterval(timer)
timer:stop()
timer:close()
end
timer:start(timeout, repeat, callback)
timer
: uv_timer_t userdata
timeout
: integer
repeat
: integer
callback
: callable
timeout
and repeat
are in milliseconds.timeout
is zero, the callback fires on the next event
loop iteration. If repeat
is non-zero, the callback fires
first after timeout
milliseconds and then repeatedly after
repeat
milliseconds.0
or fail
timer:stop()
timer
: uv_timer_t userdata
0
or fail
timer:again()
timer
: uv_timer_t userdata
EINVAL
.0
or fail
timer:set_repeat(repeat)
timer
: uv_timer_t userdata
repeat
: integer
timer:get_repeat()
timer
: uv_timer_t userdata
integer
timer:get_due_in()
timer
: uv_timer_t userdata
integer
uv_prepare_t
— Prepare handlelocal prepare = uv.new_prepare()
prepare:start(function()
print("Before I/O polling")
end)
uv_prepare_t userdata
prepare:start(callback)
prepare
: uv_prepare_t userdata
callback
: callable
0
or fail
prepare:stop()
prepare
: uv_prepare_t userdata
0
or fail
uv_check_t
— Check handlelocal check = uv.new_check()
check:start(function()
print("After I/O polling")
end)
uv_check_t userdata
check:start(callback)
check
: uv_check_t userdata
callback
: callable
0
or fail
check:stop()
check
: uv_check_t userdata
0
or fail
uv_idle_t
— Idle handlelocal idle = uv.new_idle()
idle:start(function()
print("Before I/O polling, no blocking")
end)
uv_idle_t userdata
idle:start(callback)
idle
: uv_idle_t userdata
callback
: callable
0
or fail
idle:stop()
idle
: uv_idle_t userdata
0
or fail
uv_async_t
— Async handlelocal async
async = uv.new_async(function()
print("async operation ran")
async:close()
end)
async:send()
callback
: callable
...
: threadargs
passed to/from
uv.async_send(async, ...)
uv_async_t userdata
or fail
async:send(...)
async
: uv_async_t userdata
...
: threadargs
0
or fail
uv.async_send(async)
,
that is, not every call to it will yield an execution of the
callback. For example: if uv.async_send()
is called 5 times
in a row before the callback is called, the callback will only
be called once. If uv.async_send()
is called again after the
callback was called, it will be called again.uv_poll_t
— Poll handleuv_poll_t
for any other purpose is not recommended;
uv_tcp_t, uv_udp_t, etc. provide an implementation that is faster and more
scalable than what can be achieved with uv_poll_t
, especially on Windows.fd
: integer
uv_poll_t userdata
or fail
fd
: integer
uv_poll_t userdata
or fail
poll:start(events, callback)
poll
: uv_poll_t userdata
events
: string
or nil
(default: "rw"
)
callback
: callable
err
: nil
or string
events
: string
or nil
events
are: "r"
,
"w"
, "rw"
, "d"
, "rd"
, "wd"
, "rwd"
, "p"
, "rp"
,
"wp"
, "rwp"
, "dp"
, "rdp"
, "wdp"
, or "rwdp"
where
r
is READABLE
, w
is WRITABLE
, d
is DISCONNECT
, and
p
is PRIORITIZED
. As soon as an event is detected the
callback will be called with status set to 0, and the detected
events set on the events field.0
or fail
uv.poll_start()
on a handle that is already
active is fine. Doing so will update the events mask that is
being watched for.poll:stop()
poll
: uv_poll_t userdata
0
or fail
uv_signal_t
— Signal handle-- Create a new signal handler
local signal = uv.new_signal()
-- Define a handler function
uv.signal_start(signal, "sigint", function(signal)
print("got " .. signal .. ", shutting down")
os.exit(1)
end)
uv_signal_t userdata
or fail
signal:start(signum, callback)
signal
: uv_signal_t userdata
signum
: integer
or string
callback
: callable
signum
: string
0
or fail
uv.signal_start_oneshot(){signal}
, {signum}
, {callback}
)signal:start_oneshot(signum, callback)
signal
: uv_signal_t userdata
signum
: integer
or string
callback
: callable
signum
: string
0
or fail
signal:stop()
signal
: uv_signal_t userdata
0
or fail
uv_process_t
— Process handlepath
: string
options
: table
(see below)
on_exit
: callable
code
: integer
signal
: integer
local stdin = uv.new_pipe()
local stdout = uv.new_pipe()
local stderr = uv.new_pipe()
print("stdin", stdin)
print("stdout", stdout)
print("stderr", stderr)
local handle, pid = uv.spawn("cat", {
stdio = {stdin, stdout, stderr}
}, function(code, signal) -- on exit
print("exit code", code)
print("exit signal", signal)
end)
print("process opened", handle, pid)
uv.read_start(stdout, function(err, data)
assert(not err, err)
if data then
print("stdout chunk", stdout, data)
else
print("stdout end", stdout)
end
end)
uv.read_start(stderr, function(err, data)
assert(not err, err)
if data then
print("stderr chunk", stderr, data)
else
print("stderr end", stderr)
end
end)
uv.write(stdin, "Hello World")
uv.shutdown(stdin, function()
print("stdin shutdown", stdin)
uv.close(handle, function()
print("process closed", handle, pid)
end)
end)
options.args
- Command line arguments as a list of
strings. The first string should not be the path to the
program, since that is already provided via path
. On
Windows, this uses CreateProcess which concatenates the
arguments into a string. This can cause some strange
errors (see options.verbatim
below for Windows).
options.stdio
- Set the file descriptors that will be
made available to the child process. The convention is
that the first entries are stdin, stdout, and stderr.
(Note: On Windows, file descriptors after the third are
available to the child process only if the child processes
uses the MSVCRT runtime.)
options.env
- Set environment variables for the new
process.
options.cwd
- Set the current working directory for the
sub-process.
options.uid
- Set the child process' user id.
options.gid
- Set the child process' group id.
options.verbatim
- If true, do not wrap any arguments in
quotes, or perform any other escaping, when converting the
argument list into a command line string. This option is
only meaningful on Windows systems. On Unix it is silently
ignored.
options.detached
- If true, spawn the child process in a
detached state - this will make it a process group leader,
and will effectively enable the child to keep running
after the parent exits. Note that the child process will
still keep the parent's event loop alive unless the parent
process calls uv.unref() on the child's process handle.
options.hide
- If true, hide the subprocess console
window that would normally be created. This option is only
meaningful on Windows systems. On Unix it is silently
ignored.
options.stdio
entries can take many shapes.nil
placeholders means to ignore that fd in
the child process.
on_exit
is called with an exit
code and signal.uv_process_t userdata
, integer
process:kill(signum)
process
: uv_process_t userdata
signum
: integer
or string
or nil
(default: sigterm
)
0
or fail
pid
: integer
signum
: integer
or string
or nil
(default: sigterm
)
0
or fail
process:get_pid()
process
: uv_process_t userdata
integer
uv_stream_t
— Stream handleuv_stream_t
is an abstract type, libuv provides 3 stream implementations
in the form of uv_tcp_t, uv_pipe_t and uv_tty_t.stream:shutdown([callback])
callback
: callable
or nil
err
: nil
or string
uv_shutdown_t userdata
or fail
stream:listen(backlog, callback)
backlog
: integer
callback
: callable
err
: nil
or string
backlog
indicates
the number of connections the kernel might queue, same as
listen(2)
. When a new incoming connection is received the
callback is called.0
or fail
stream:accept(client_stream)
0
or fail
server:listen(128, function (err)
local client = uv.new_tcp()
server:accept(client)
end)
stream:read_start(callback)
callback
: callable
err
: nil
or string
data
: string
or nil
data
will be nil
.0
or fail
stream:read_start(function (err, chunk)
if err then
-- handle read error
elseif chunk then
-- handle data
else
-- handle disconnect
end
end)
stream:read_stop()
0
or fail
stream:write(data, [callback])
data
: buffer
callback
: callable
or nil
err
: nil
or string
data
can either be a Lua string or a table of strings. If a
table is passed in, the C backend will use writev to send all
strings in a single system call.callback
is for knowing when the write is
complete.uv_write_t userdata
or fail
stream:write2(data, send_handle, [callback])
data
: buffer
callback
: callable
or nil
err
: nil
or string
ipc
option true
.uv_write_t userdata
or fail
send_handle
must be a TCP socket or pipe, which is a
server or a connection (listening or connected state). Bound
sockets or pipes will be assumed to be servers.stream:try_write(data)
data
: buffer
integer
or fail
stream:try_write2(data, send_handle)
data
: buffer
UV_EAGAIN
.integer
or fail
stream:is_readable()
true
if the stream is readable, false
otherwise.boolean
stream:is_writable()
true
if the stream is writable, false
otherwise.boolean
stream:set_blocking(blocking)
blocking
: boolean
0
or fail
stream:get_write_queue_size()
integer
uv_tcp_t
— TCP handleflags
: string
or nil
"unix"
,
"inet"
, "inet6"
, "ipx"
, "netlink"
, "x25"
, "ax25"
,
"atmpvc"
, "appletalk"
, or "packet"
.uv_tcp_t userdata
or fail
tcp:open(sock)
tcp
: uv_tcp_t userdata
sock
: integer
0
or fail
tcp:nodelay(enable)
tcp
: uv_tcp_t userdata
enable
: boolean
0
or fail
tcp:keepalive(enable, [delay])
tcp
: uv_tcp_t userdata
enable
: boolean
delay
: integer
or nil
delay
is the initial delay
in seconds, ignored when enable is false
.0
or fail
tcp:simultaneous_accepts(enable)
tcp
: uv_tcp_t userdata
enable
: boolean
0
or fail
tcp:bind(host, port, [flags])
tcp
: uv_tcp_t userdata
host
: string
port
: integer
flags
: table
or nil
ipv6only
: boolean
host
should be an IP
address and not a domain name. Any flags
are set with a
table with field ipv6only
equal to true
or false
.EADDRINUSE
error from either uv.tcp_bind()
, uv.listen()
or uv.tcp_connect(). That is, a successful call to this
function does not guarantee that the call to uv.listen() or
uv.tcp_connect() will succeed as well.0
to let the OS assign an ephemeral port. You
can look it up later using uv.tcp_getsockname().0
or fail
tcp:getpeername()
tcp
: uv_tcp_t userdata
table
or fail
ip
: string
family
: string
port
: integer
tcp:getsockname()
tcp
: uv_tcp_t userdata
table
or fail
ip
: string
family
: string
port
: integer
tcp:connect(host, port, callback)
tcp
: uv_tcp_t userdata
host
: string
port
: integer
callback
: callable
err
: nil
or string
uv_connect_t userdata
or fail
local client = uv.new_tcp()
client:connect("127.0.0.1", 8080, function (err)
-- check error and carry on.
end)
tcp:write_queue_size()
tcp:close_reset([callback])
tcp
: uv_tcp_t userdata
callback
: callable
or nil
uv.tcp_close_reset()
calls is not allowed.0
or fail
uv.socketpair(){socktype}
, [{protocol}
, [{flags1}
, [{flags2}
]]]])socktype
: string
, integer
or nil
(default: stream
)
protocol
: string
, integer
or nil
(default: 0)
flags1
: table
or nil
nonblock
: boolean
(default: false
)
flags2
: table
or nil
nonblock
: boolean
(default: false
)
socktype
must be one of
"stream"
, "dgram"
, "raw"
, "rdm"
, or "seqpacket"
.protocol
is set to 0 or nil, it will be automatically
chosen based on the socket's domain and type. When protocol
is specified as a string, it will be looked up using the
getprotobyname(3)
function (examples: "ip"
, "icmp"
,
"tcp"
, "udp"
, etc).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.
socketpair(2)
with a domain of AF_UNIX
.table
or fail
[1, 2]
: integer
(file descriptor)
-- Simple read/write with tcp
local fds = uv.socketpair(nil, nil, {nonblock=true}, {nonblock=true})
local sock1 = uv.new_tcp()
sock1:open(fds[1])
local sock2 = uv.new_tcp()
sock2:open(fds[2])
sock1:write("hello")
sock2:read_start(function(err, chunk)
assert(not err, err)
print(chunk)
end)
uv_pipe_t
— Pipe handlelocal pipe = uv.new_pipe(false)
pipe:bind('/tmp/sock.test')
pipe:listen(128, function()
local client = uv.new_pipe(false)
pipe:accept(client)
client:write("hello!\n")
client:close()
end)
ipc
: boolean
or nil
(default: false
)
ipc
argument is a boolean to
indicate if this pipe will be used for handle passing between
processes.uv_pipe_t userdata
or fail
pipe:open(fd)
pipe
: uv_pipe_t userdata
fd
: integer
0
or fail
pipe:bind(name)
pipe
: uv_pipe_t userdata
name
: string
0
or fail
pipe:connect(name, [callback])
pipe
: uv_pipe_t userdata
name
: string
callback
: callable
or nil
err
: nil
or string
uv_connect_t userdata
or fail
pipe:getsockname()
pipe
: uv_pipe_t userdata
string
or fail
pipe:getpeername()
pipe
: uv_pipe_t userdata
string
or fail
pipe:pending_instances(count)
pipe
: uv_pipe_t userdata
count
: integer
pipe:pending_count()
pipe
: uv_pipe_t userdata
integer
pipe:pending_type()
pipe
: uv_pipe_t userdata
uv.pipe_pending_type()
and call uv.accept(pipe, handle)
.string
pipe:chmod(flags)
pipe
: uv_pipe_t userdata
flags
: string
flags
are: "r"
, "w"
, "rw"
, or
"wr"
where r
is READABLE
and w
is WRITABLE
. This
function is blocking.0
or fail
read_flags
: table
or nil
nonblock
: boolean
(default: false
)
write_flags
: table
or nil
nonblock
: boolean
(default: false
)
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.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.
pipe(2)
with the O_CLOEXEC
flag set.table
or fail
read
: integer
(file descriptor)
write
: integer
(file descriptor)
-- 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)
pipe:pipe_bind(name, flags)
pipe
: uv_pipe_t userdata
name
: string
flags
: integer
or table
or nil
(default: 0)
type(flags)
is number
, it must be 0
or
uv.constants.PIPE_NO_TRUNCATE
.
type(flags)
is table
, it must be {}
or
{ no_truncate = true|false }
.
type(flags)
is nil
, it use default value 0
.
EINVAL
for unsupported flags without performing the
bind.
0
or fail
pipe:connect2(name, [flags], [callback])
pipe
: uv_pipe_t userdata
name
: string
flags
: integer
or table
or nil
(default: 0)
callback
: callable
or nil
err
: nil
or string
Flags
:type(flags)
is number
, it must be 0
or
uv.constants.PIPE_NO_TRUNCATE
.
type(flags)
is table
, it must be {}
or
{ no_truncate = true|false }
.
type(flags)
is nil
, it use default value 0
.
EINVAL
for unsupported flags without performing the
bind operation.
uv_connect_t userdata
or fail
uv_tty_t
— TTY handle-- 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)
fd
: integer
readable
: boolean
uv_tty_t userdata
or fail
tty:set_mode(mode)
tty
: uv_tty_t userdata
mode
: integer
mode
is a C enum with the following values:0
or fail
EBUSY
if you call it when execution is
inside uv.tty_set_mode().0
or fail
tty:get_winsize()
tty
: uv_tty_t userdata
integer, integer
or fail
state
: string
"supported"
or
"unsupported"
."supported"
or "unsupported"
.ENOTSUP
.string
or fail
uv_udp_t
— UDP handleflags
: table
or nil
family
: string
or nil
mmsgs
: integer
or nil
(default: 1
)
family
must be one of "unix"
, "inet"
,
"inet6"
, "ipx"
, "netlink"
, "x25"
, "ax25"
,
"atmpvc"
, "appletalk"
, or "packet"
.mmsgs
determines the number of messages able
to be received at one time via recvmmsg(2)
(the allocated
buffer will be sized to be able to fit the specified number of
max size dgrams). Only has an effect on platforms that support
recvmmsg(2)
.flags
can also be
a string or integer. When it is a string, it will be treated
like the family
key above. When it is an integer, it will be
used directly as the flags
parameter when calling
uv_udp_init_ex
.uv_udp_t userdata
or fail
udp:get_send_queue_size()
integer
udp:get_send_queue_count()
integer
udp:open(fd)
udp
: uv_udp_t userdata
fd
: integer
0
or fail
udp:bind(host, port, [flags])
udp
: uv_udp_t userdata
host
: string
port
: number
flags
: table
or nil
ipv6only
: boolean
reuseaddr
: boolean
flags
are
set with a table with fields reuseaddr
or ipv6only
equal
to true
or false
.0
or fail
udp:getsockname()
udp
: uv_udp_t userdata
table
or fail
ip
: string
family
: string
port
: integer
udp:getpeername()
udp
: uv_udp_t userdata
table
or fail
ip
: string
family
: string
port
: integer
{udp}
, {multicast_addr}
, {interface_addr}
, {membership}
)udp:set_membership(multicast_addr, interface_addr, membership)
udp
: uv_udp_t userdata
multicast_addr
: string
interface_addr
: string
or nil
membership
: string
multicast_addr
is
multicast address to set membership for. interface_addr
is
interface address. membership
can be the string "leave"
or
"join"
.0
or fail
{udp}
, {multicast_addr}
, {interface_addr}
, {source_addr}
, {membership}
)udp:set_source_membership(multicast_addr, interface_addr, source_addr, membership)
udp
: uv_udp_t userdata
multicast_addr
: string
interface_addr
: string
or nil
source_addr
: string
membership
: string
multicast_addr
is multicast address to set membership for.
interface_addr
is interface address. source_addr
is source
address. membership
can be the string "leave"
or "join"
.0
or fail
udp:set_multicast_loop(on)
udp
: uv_udp_t userdata
on
: boolean
0
or fail
udp:set_multicast_ttl(ttl)
udp
: uv_udp_t userdata
ttl
: integer
ttl
is an integer 1 through 255.0
or fail
udp:set_multicast_interface(interface_addr)
udp
: uv_udp_t userdata
interface_addr
: string
0
or fail
udp:set_broadcast(on)
udp
: uv_udp_t userdata
on
: boolean
0
or fail
udp:set_ttl(ttl)
udp
: uv_udp_t userdata
ttl
: integer
ttl
is an integer 1 through 255.0
or fail
udp:send(data, host, port, callback)
udp
: uv_udp_t userdata
data
: buffer
host
: string
port
: integer
callback
: callable
err
: nil
or string
0.0.0.0
(the "all interfaces" IPv4 address) and a random
port number.uv_udp_send_t userdata
or fail
udp:try_send(data, host, port)
udp
: uv_udp_t userdata
data
: buffer
host
: string
port
: integer
integer
or fail
udp:recv_start(callback)
udp
: uv_udp_t userdata
callback
: callable
err
: nil
or string
data
: string
or nil
addr
: table
or nil
ip
: string
port
: integer
family
: string
flags
: table
partial
: boolean
or nil
mmsg_chunk
: boolean
or nil
0.0.0.0
(the
"all interfaces" IPv4 address) and a random port number.0
or fail
udp:recv_stop()
udp
: uv_udp_t userdata
0
or fail
udp:connect(host, port)
udp
: uv_udp_t userdata
host
: string
port
: integer
uv.udp_connect()
on
an already connected handle will result in an EISCONN
error.
Trying to disconnect a handle that is not connected will
return an ENOTCONN
error.0
or fail
uv_fs_event_t
— FS Event handleuv_fs_event_t userdata
or fail
fs_event:start(path, flags, callback)
fs_event
: uv_fs_event_t userdata
path
: string
flags
: table
watch_entry
: boolean
or nil
(default: false
)
stat
: boolean
or nil
(default: false
)
recursive
: boolean
or nil
(default: false
)
callback
: callable
err
: nil
or string
filename
: string
events
: table
change
: boolean
or nil
rename
: boolean
or nil
0
or fail
fs_event:stop()
0
or fail
fs_event:getpath()
string
or fail
uv_fs_poll_t
— FS Poll handlestat
to detect when a file has changed
so they can work on file systems where fs event handles can't.uv_fs_poll_t userdata
or fail
fs_poll:start(path, interval, callback)
fs_poll
: uv_fs_poll_t userdata
path
: string
interval
: integer
callback
: callable
err
: nil
or string
prev
: table
or nil
(see uv.fs_stat
)
curr
: table
or nil
(see uv.fs_stat
)
path
for changes every interval
milliseconds.0
or fail
fs_poll:stop()
0
or fail
fs_poll:getpath()
string
or fail
uv_fs_t userdata
and asynchronously execute its callback; if an error is
encountered, the first and only argument passed to the callback will be the
err
error string; if the operation completes successfully, the first
argument will be nil
and the remaining arguments will be the results of the
FS call.readFile
(with naive error
handling) are implemented below as an example:local function readFileSync(path)
local fd = assert(uv.fs_open(path, "r", 438))
local stat = assert(uv.fs_fstat(fd))
local data = assert(uv.fs_read(fd, stat.size, 0))
assert(uv.fs_close(fd))
return data
end
local data = readFileSync("main.lua")
print("synchronous read", data)
local function readFile(path, callback)
uv.fs_open(path, "r", 438, function(err, fd)
assert(not err, err)
uv.fs_fstat(fd, function(err, stat)
assert(not err, err)
uv.fs_read(fd, stat.size, 0, function(err, data)
assert(not err, err)
uv.fs_close(fd, function(err)
assert(not err, err)
return callback(data)
end)
end)
end)
end)
end
readFile("main.lua", function(data)
print("asynchronous read", data)
end)
fd
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
close(2)
.boolean
or fail
uv_fs_t userdata
path
: string
flags
: string
or integer
mode
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
fd
: integer
or nil
open(2)
. Access flags
may be an integer or
one of: "r"
, "rs"
, "sr"
, "r+"
, "rs+"
, "sr+"
,
"w"
, "wx"
, "xw"
, "w+"
, "wx+"
, "xw+"
, "a"
,
"ax"
, "xa"
, "a+"
, "ax+"
, or "`xa+`".integer
or fail
uv_fs_t userdata
CreateFileW
and thus the file
is always opened in binary mode. Because of this, the
O_BINARY
and O_TEXT
flags are not supported.fd
: integer
size
: integer
offset
: integer
or nil
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
data
: string
or nil
preadv(2)
. Returns any data. An empty string
indicates EOF.offset
is nil or omitted, it will default to -1
, which
indicates "use and update the current file offset."offset
is >= 0, the current file offset will not
be updated by the read.string
or fail
uv_fs_t userdata
path
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
unlink(2)
.boolean
or fail
uv_fs_t userdata
fd
: integer
data
: buffer
offset
: integer
or nil
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
bytes
: integer
or nil
pwritev(2)
. Returns the number of bytes
written.offset
is nil or omitted, it will default to -1
, which
indicates "use and update the current file offset."offset
is >= 0, the current file offset will not
be updated by the write.integer
or fail
uv_fs_t userdata
path
: string
mode
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
mkdir(2)
.boolean
or fail
uv_fs_t userdata
template
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
path
: string
or nil
mkdtemp(3)
.string
or fail
uv_fs_t userdata
template
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
fd
: integer
or nil
path
: string
or nil
mkstemp(3)
. Returns a temporary file handle
and filename.integer, string
or fail
uv_fs_t userdata
path
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
rmdir(2)
.boolean
or fail
uv_fs_t userdata
path
: string
callback
: callable
err
: nil
or string
success
: uv_fs_t userdata
or nil
scandir(3)
, with a slightly different API.
Returns a handle that the user can pass to
uv.fs_scandir_next().uv_fs_t userdata
or fail
fs
: uv_fs_t userdata
name, type
pair. When there
are no more entries, nil
is returned.string, string
or nil
or fail
path
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
stat
: table
or nil
(see below)
stat(2)
.table
or fail
dev
: integer
mode
: integer
nlink
: integer
uid
: integer
gid
: integer
rdev
: integer
ino
: integer
size
: integer
blksize
: integer
blocks
: integer
flags
: integer
gen
: integer
atime
: table
sec
: integer
nsec
: integer
mtime
: table
sec
: integer
nsec
: integer
ctime
: table
sec
: integer
nsec
: integer
birthtime
: table
sec
: integer
nsec
: integer
type
: string
uv_fs_t userdata
fd
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
stat
: table
or nil
(see uv.fs_stat
)
fstat(2)
.table
or fail
(see uv.fs_stat
)uv_fs_t userdata
path
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
stat
: table
or nil
(see uv.fs_stat
)
lstat(2)
.uv_fs_t userdata
path
: string
new_path
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
rename(2)
.boolean
or fail
uv_fs_t userdata
fd
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
fsync(2)
.boolean
or fail
uv_fs_t userdata
fd
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
fdatasync(2)
.boolean
or fail
uv_fs_t userdata
fd
: integer
offset
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
ftruncate(2)
.boolean
or fail
uv_fs_t userdata
out_fd
: integer
in_fd
: integer
in_offset
: integer
size
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
bytes
: integer
or nil
sendfile(2)
. Returns the number of
bytes written.integer
or fail
uv_fs_t userdata
path
: string
mode
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
permission
: boolean
or nil
access(2)
on Unix. Windows uses
GetFileAttributesW()
. Access mode
can be an integer or a
string containing "R"
or "W"
or "X"
. Returns true
or
false
indicating access permission.boolean
or fail
uv_fs_t userdata
path
: string
mode
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
chmod(2)
.boolean
or fail
uv_fs_t userdata
fd
: integer
mode
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
fchmod(2)
.boolean
or fail
uv_fs_t userdata
path
: string
atime
: number
mtime
: number
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
utime(2)
.boolean
or fail
uv_fs_t userdata
fd
: integer
atime
: number
mtime
: number
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
futime(2)
.boolean
or fail
uv_fs_t userdata
path
: string
atime
: number
mtime
: number
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
lutime(2)
.boolean
or fail
uv_fs_t userdata
path
: string
new_path
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
link(2)
.boolean
or fail
uv_fs_t userdata
path
: string
new_path
: string
flags
: table
, integer
, or nil
dir
: boolean
junction
: boolean
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
symlink(2)
. If the flags
parameter is
omitted, then the 3rd parameter will be treated as the
callback
.boolean
or fail
uv_fs_t userdata
path
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
path
: string
or nil
readlink(2)
.string
or fail
uv_fs_t userdata
path
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
path
: string
or nil
realpath(3)
.string
or fail
uv_fs_t userdata
path
: string
uid
: integer
gid
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
chown(2)
.boolean
or fail
uv_fs_t userdata
fd
: integer
uid
: integer
gid
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
fchown(2)
.boolean
or fail
uv_fs_t userdata
fd
: integer
uid
: integer
gid
: integer
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
lchown(2)
.boolean
or fail
uv_fs_t userdata
path
: string
new_path
: string
flags
: table
, integer
, or nil
excl
: boolean
ficlone
: boolean
ficlone_force
: boolean
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
flags
parameter
is omitted, then the 3rd parameter will be treated as the
callback
.boolean
or fail
uv_fs_t userdata
path
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
dir
: luv_dir_t userdata
or nil
entries
: integer
or nil
entries
parameter
defines the maximum number of entries that should be returned
by each call to uv.fs_readdir().luv_dir_t userdata
or fail
uv_fs_t userdata
dir:readdir([callback])
dir
: luv_dir_t userdata
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
entries
: table
or nil
(see below)
luv_dir_t
returned by a
successful uv.fs_opendir() call. A table of data tables is
returned where the number of entries n
is equal to or less
than the entries
parameter used in the associated
uv.fs_opendir() call.table
or fail
[1, 2, 3, ..., n]
: table
name
: string
type
: string
uv_fs_t userdata
dir:closedir([callback])
dir
: luv_dir_t userdata
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
success
: boolean
or nil
boolean
or fail
uv_fs_t userdata
path
: string
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
table
or nil
(see below)
statfs(2)
.table
or nil
type
: integer
bsize
: integer
blocks
: integer
bfree
: integer
bavail
: integer
files
: integer
ffree
: integer
getaddrinfo
and getnameinfo
requests.local function work_callback(a, b)
return a + b
end
local function after_work_callback(c)
print("The result is: " .. c)
end
local work = uv.new_work(work_callback, after_work_callback)
work:queue(1, 2)
-- output: "The result is: 3"
work_callback
: function
or string
...
: threadargs
passed to/from
uv.queue_work(work_ctx, ...)
after_work_callback
: function
...
: threadargs
returned from work_callback
luv_work_ctx_t
(not
uv_work_t
).
work_callback
is a Lua function or a string containing Lua
code or bytecode dumped from a function. Returns the Lua
userdata wrapping it.luv_work_ctx_t userdata
work_ctx:queue(...)
work_ctx
: luv_work_ctx_t userdata
...
: threadargs
work_callback
in a new
Lua state in a thread from the threadpool with any additional
arguments from ...
. Values returned from work_callback
are
passed to after_work_callback
, which is called in the main
loop thread.boolean
or fail
host
: string
or nil
service
: string
or nil
hints
: table
or nil
family
: string
or integer
or nil
socktype
: string
or integer
or nil
protocol
: string
or integer
or nil
addrconfig
: boolean
or nil
v4mapped
: boolean
or nil
all
: boolean
or nil
numerichost
: boolean
or nil
passive
: boolean
or nil
numericserv
: boolean
or nil
canonname
: boolean
or nil
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
addresses
: table
or nil
(see below)
getaddrinfo(3)
. Either node
or service
may
be nil
but not both.family
: "unix"
, "inet"
, "inet6"
, "ipx"
,
"netlink"
, "x25"
, "ax25"
, "atmpvc"
, "appletalk"
,
or "packet"
socktype
: "stream"
, "dgram"
, "raw"
, "rdm"
, or
"seqpacket"
protocol
: will be looked up using the getprotobyname(3)
function (examples: "ip"
, "icmp"
, "tcp"
, "udp"
, etc)
table
or fail
[1, 2, 3, ..., n]
: table
addr
: string
family
: string
port
: integer
or nil
socktype
: string
protocol
: string
canonname
: string
or nil
uv_getaddrinfo_t userdata
or fail
address
: table
ip
: string
or nil
port
: integer
or nil
family
: string
or integer
or nil
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
host
: string
or nil
service
: string
or nil
getnameinfo(3)
.family
must be one of "unix"
, "inet"
,
"inet6"
, "ipx"
, "netlink"
, "x25"
, "ax25"
,
"atmpvc"
, "appletalk"
, or "packet"
.string, string
or fail
uv_getnameinfo_t userdata
or fail
options
: table
or nil
stack_size
: integer
or nil
entry
: function
or string
...
: threadargs
passed to entry
luv_thread_t
(not uv_thread_t
).
Returns the Lua userdata wrapping it and asynchronously
executes entry
, which can be either a Lua function or a
string containing Lua code or bytecode dumped from a function.
Additional arguments ...
are passed to the entry
function
and an optional options
table may be provided. Currently
accepted option
fields are stack_size
.luv_thread_t userdata
or fail
thread:equal(other_thread)
thread
: luv_thread_t userdata
other_thread
: luv_thread_t userdata
__eq
metamethod.boolean
uv.thread_setaffinity(){thread}
, {affinity}
[, {get_old_affinity}
])thread:setaffinity(affinity, [get_old_affinity])
thread
: luv_thread_t userdata
affinity
: table
[1, 2, 3, ..., n]
: boolean
get_old_affinity
: boolean
affinity
must be a table where each of the keys are a CPU
number and the values are booleans that represent whether the
thread
should be eligible to run on that CPU. If the length
of the affinity
table is not greater than or equal to
uv.cpumask_size(), any CPU numbers missing from the table
will have their affinity set to false
. If setting the
affinity of more than uv.cpumask_size() CPUs is desired,
affinity
must be an array-like table with no gaps, since
#affinity
will be used as the cpumask_size
if it is
greater than uv.cpumask_size().get_old_affinity
is true
, the previous affinity
settings for the thread
will be returned. Otherwise, true
is returned after a successful call.table
or boolean
or fail
[1, 2, 3, ..., n]
: boolean
thread:getaffinity([mask_size])
thread
: luv_thread_t userdata
mask_size
: integer
mask_size
is provided, it must be greater than or equal
to uv.cpumask_size()
. If the mask_size
parameter is
omitted, then the return of uv.cpumask_size()
will be used.
Returns an array-like table where each of the keys correspond
to a CPU number and the values are booleans that represent
whether the thread
is eligible to run on that CPU.table
or fail
[1, 2, 3, ..., n]
: boolean
uv.thread_getaffinity
and uv.thread_setaffinity
.integer
or fail
thread:setpriority(priority)
thread
: luv_thread_t userdata
priority
: number
uv.constants.THREAD_PRIORITY_HIGHEST
uv.constants.THREAD_PRIORITY_ABOVE_NORMAL
uv.constants.THREAD_PRIORITY_NORMAL
uv.constants.THREAD_PRIORITY_BELOW_NORMAL
uv.constants.THREAD_PRIORITY_LOWEST
boolean
or fail
thread:getpriority()
thread
: luv_thread_t userdata
number
or fail
luv_thread_t
thread:join()
thread
: luv_thread_t userdata
thread
to finish executing its entry function.boolean
or fail
msec
: integer
string
or fail
string
or fail
cwd
: string
cwd
.0
or fail
string
or fail
title
: string
title
.0
or fail
number
number
number
uv.get_free_memory()
in that it takes into account any limits imposed by the OS. If
there is no such constraint, or the constraint is unknown, the
amount returned will be identical to uv.get_free_memory()
.number
integer
or fail
table
or fail
utime
: table
(user CPU time used)
sec
: integer
usec
: integer
stime
: table
(system CPU time used)
sec
: integer
usec
: integer
maxrss
: integer
(maximum resident set size)
ixrss
: integer
(integral shared memory size)
idrss
: integer
(integral unshared data size)
isrss
: integer
(integral unshared stack size)
minflt
: integer
(page reclaims (soft page faults))
majflt
: integer
(page faults (hard page faults))
nswap
: integer
(swaps)
inblock
: integer
(block input operations)
oublock
: integer
(block output operations)
msgsnd
: integer
(IPC messages sent)
msgrcv
: integer
(IPC messages received)
nsignals
: integer
(signals received)
nvcsw
: integer
(voluntary context switches)
nivcsw
: integer
(involuntary context switches)
integer
table
or fail
[1, 2, 3, ..., n]
: table
model
: string
speed
: number
times
: table
user
: number
nice
: number
sys
: number
idle
: number
irq
: number
ENOTSUP
if affinities are not supported on
the current platform.integer
or fail
integer
integer
id
: integer
id
.id
: integer
id
.number
clock_id
: string
clock_id
can be the
string "monotonic"
or "realtime"
.table
or fail
sec
: integer
nsec
: integer
number
or fail
[flags] handle-type handle-address
. Flags are
R
for referenced, A
for active and I
for internal.fd
: integer
fd
. Usually this will be used during
initialization to guess the type of the stdio streams.string
gettimeofday(2)
. Returns
the seconds and microseconds of a unix time as a pair.integer, integer
or fail
ip
, family
, netmask
,
internal
, and mac
.table
[name(s)]
: table
ip
: string
family
: string
netmask
: string
internal
: boolean
mac
: string
ifindex
: integer
if_indextoname(3)
.string
or fail
ifindex
: integer
ifindex
as a string. On all other platforms,
uv.if_indextoname() is used.string
or fail
number, number, number
table
sysname
: string
release
: string
version
: string
machine
: string
string
name
: string
size
: integer
(default = LUAL_BUFFERSIZE
)
name
as
string. The internal buffer size can be set by defining
size
. If omitted, LUAL_BUFFERSIZE
is used. If the
environment variable exceeds the storage available in the
internal buffer, ENOBUFS
is returned. If no matching
environment variable exists, ENOENT
is returned.string
or fail
name
: string
value
: string
name
with the
string value
.boolean
or fail
name
: string
name
.boolean
or fail
table
string
or fail
string
or fail
table
username
: string
uid
: integer
gid
: integer
shell
: string
homedir
: string
number
number
pid
: integer
pid
.number
or fail
pid
: integer
priority
: integer
pid
. The priority
range is between -20 (high priority) and
19 (low priority).boolean
or fail
len
: integer
flags
: nil
(see below)
callback
: callable
(async version) or nil
(sync
version)
err
: nil
or string
bytes
: string
or nil
len
with cryptographically strong
random bytes acquired from the system CSPRNG. flags
is
reserved for future extension and must currently be nil
or
0
or {}
.len
random
bytes are available, a non-zero error value is returned or
passed to the callback. If the callback is omitted, this
function is completed synchronously.string
or fail
0
or fail
errcode
: integer
err
and name
in luv-error-handling) equivalent
to the given platform dependent error code: POSIX error codes
on Unix (the ones stored in errno), and Win32 error codes on
Windows (those returned by GetLastError() or
WSAGetLastError()).string, string
or nil
epoll_wait
). The call is
thread safe.loop_configure
with
"metrics_idle_time"
.number
prepare
callback (see uv.new_prepare(), uv.prepare_start()) in order
to make sure there are no inconsistencies with the metrics
counters.table
loop_count
: integer
events
: integer
events_waiting
: integer