Previously, we required the user to specify the expected read/write
flags for a pipe or tty. But we've already been asking the OS to tell us
what they actually are (fcntl F_GETFL), so we can hopefully just use
that information directly.
Fixes: https://github.com/libuv/libuv/issues/1936
PR-URL: https://github.com/libuv/libuv/pull/1964
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Some long overdue refactoring that unifies more of the UNIX and Windows
backends.
PR-URL: https://github.com/libuv/libuv/pull/1904
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Using -errno, -E**, and -pthread_function() can be
error prone, and breaks compatibility with some operating
systems that already negate errno's (e.g. Haiku).
This commit adds a UV__ERR() macro that ensures libuv
errors are negative.
Fixes: https://github.com/libuv/help/issues/39
PR-URL: https://github.com/libuv/libuv/pull/1687
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
NetBSD as an extension returns with ptsname(3) and ptsname_r(3) the
slave device name for both descriptors, the master one and slave one.
Workaround this problem and verify the device major and compare it with
the pts driver. Major numbers for the master and the slave TTY are
machine-dependent. On amd64 they are respectively 6 (ptc) and 5 (pts).
PR-URL: https://github.com/libuv/libuv/pull/1533
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
autotools support only, gvp does not support kfreebsd detection.
PR-URL: https://github.com/libuv/libuv/pull/960
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
- zos: disable test cases not applicable
- zos: build options
- zos: semaphore implementation
- zos: use compare and swap builtins
- zos: struct rusage not the same as other platforms
- zos: backlog<=0 produces undefined behaviour
Will redefine backlog in the following way
* if backlog == 0, set it to 1
* if backlog < 0, set it to SOMAXCONN
- zos: define IMAXBEL as empty flag and implement uv__tty_make_raw
- zos: use udp multicast operations from aix
- zos: ESC in ebcdic
- zos: use LIBPATH for dynamic linker path
- zos: uv_udp_set_ttl only works for ipv6
- zos: increase pthread stack size by factor of 4
- zos: return ENODEV instead of ENXIO errors for setsockopt
- zos: use uv_cond_init the same way as aix
- test: enable oob test for zos
- zos: return EINVAL for zos error code EOPNOTSUPP
PR-URL: https://github.com/libuv/libuv/pull/937
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This fixes test-stdio-over-pipes and test-pipe-sendmsg test cases.
~~~~
Assertion failed in test/test-stdio-over-pipes.c on line 56: term_signal == 0
Assertion failed in test/test-pipe-sendmsg.c on line 86: pending == UV_NAMED_PIPE
~~~~
This fixes a longstanding issue with nodejs on DragonFly, which was
triggered whenever spawning a process and pipes were involed.
PR-URL: https://github.com/libuv/libuv/pull/884
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Imran Iqbal <imran@imraniqbal.org>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Find the real name of the tty using ttyname_r(3) instead of
opening "/dev/tty" which causes trouble if the fd doesn't point to the
controlling terminal.
PR-URL: https://github.com/libuv/libuv/pull/779
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
On AIX, the getsockname API does not operate on the UNIX domain sockets
Please see: https://www-01.ibm.com/support/knowledgecenter/ssw_aix_61/
com.ibm.aix.commtrf2/getsockname.htm
This means that the internal helper routine uv_guess_handle in tty.c
fails in AIX, for common use cases.
There is no direct API support which helps identifying a UNIX domain
socket in AIX. getpeername() retrieves the information pertinent to
connected UNIX domain socket pairs, and using getpeername where
getsockname fails was a good workaround. However, there are edge cases
where one end of a socketpair comes for introspection while the other
end has been closed, which causes getpeername to fail.
A better solution is derived based on these facts:
1.getsockname() on a broken / un-broken socketpair does not actually
fail with -1, instead it returns 0. However, the API does not modify
the socketaddr structure passed to it, with the socket information.
2.This behavior of getsockname is observed only for UNIX domain socket,
among all possible types of sockets which I tested - ~30 of them.
So a practical and stable workaround for AIX is to return
UV_UNKNOWN_HANDLE if getsockname fails. If it passes and the length
of the structure returned is 0 then we know that the type is AF_UNIX
and return UV_NAMED_PIPE , otherwise we inspect in the same way as for
other platforms to derive the type.
PR-URL: https://github.com/libuv/libuv/pull/539
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Once we are past uv__stream_init, the handle has been added to
loop->handle_queue, it needs to be undone in case of failure.
PR-URL: https://github.com/libuv/libuv/pull/414
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
uv_tty_reset_mode() is designed to be async signal-safe and is therefore
not allowed to clobber errno.
PR-URL: https://github.com/libuv/libuv/pull/259
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
On Solaris derivatives, cfmakeraw is not available. Instead, set the
termios flags manually. The set of flags to use so that the behavior of
the terminal is similar to what it is after a call to cfmakeraw was
taken from
http://www.perkin.org.uk/posts/solaris-portability-cfmakeraw.html.
PR-URL: https://github.com/libuv/libuv/pull/210
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
The mode argument is an enum now and the signedness of an enum is
implementation-defined when it doesn't have negative members.
Cast it to int in the comparison to tty->mode because the latter is
still an int.
PR: https://github.com/libuv/libuv/pull/134
Reviewed-by: Saúl Ibarra Corretgé <saghul@gmail.com>
Introduce a uv_tty_mode_t enum for uv_tty_set_mode(), with backward
compatible values. Add a new mode UV_TTY_MODE_IO, which uses
cfmakeraw() internally.
PR-URL: https://github.com/libuv/libuv/pull/86
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This reverts commit 0f25560c8a.
This change was introduced to make it possible to use the TTY for binary
I/O but unfortunately it breaks libuv users that depend on the OPOST and
ONLCR flags, like node.js.
There is no point in adding those flags after the call to cfmakeraw()
because that would once again make the TTY unsuitable for binary I/O.
Let's revert it for now and revisit it again later.
Fixeslibuv/libuv#32, reverts joyent/libuv#1567.
PR-URL: https://github.com/libuv/libuv/pull/33
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
In case reopening the file descriptor fails, fallback to the old
behavior where we do blocking writes, to avoid disrupting other
processes potentially using the file descriptor.
Reopen the file descriptor when it refers to a tty. This lets us put the
tty in non-blocking mode without affecting other processes that share it
with us.
This brings back commit 31f9fbc, which was reverted in 20bb1bf. The OSX
select trick is working now.
Original patch by @bnoordhuis
Make it possible to call uv_tty_reset_mode() from inside a signal
handler. The primary motivation is to make it possible to restore
the TTY from inside a SIGINT or SIGTERM signal handler.
Fixes#954.
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.
A code snippet like this one:
if (uv_foo(loop) < 0) {
uv_err_t err = uv_last_error(loop);
fprintf(stderr, "%s\n", uv_strerror(err));
}
Should be rewritten like this:
int err = uv_foo(loop);
if (err < 0)
fprintf(stderr, "%s\n", uv_strerror(err));
The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
uv_guess_handle is currently squelching both fifo and all
sockets on to the UV_NAMED_PIPE type. Rather than treating
all sockets as UV_NAMED_PIPE, use getsockopt() and
getsockaddr() to determine if the socket is an AF_UNIX
stream (in which case return UV_NAMED_PIPE), or an AF_INET
stream (in which case return UV_TCP), or an AF_INET datagram
socket (in which case return UV_UDP).
Additionally, currently all other file descriptor types are
squelched to the UV_FILE type. Instead, only file descriptors
that are marked as regular files are treated as UV_FILE. All
other types (such as directories, character and block devices)
are now treated as UV_UNKNOWN_HANDLE.
kqueue(2) on osx doesn't work (emits EINVAL error) with specific fds
(i.e. /dev/tty, /dev/null, etc). When given such descriptors - start
select(2) watcher thread that will emit io events.
This reverts commit 31f9fbce63.
The reverted commit depends on commit 5da380a ("use select() for specific fds
on OS X") which polls /dev/tty file descriptors in a separate thread to work
around deficiencies in the kqueue API on OS X.
Unfortunately, 5da380a has a bug that effectively makes the select() thread
busy-loop. Revert this commit for now.
Reopen the file descriptor when it refers to a tty. This lets us put the tty in
non-blocking mode without affecting other processes that share it with us.
Fixes#601.
Drain, don't flush the tty when switching from cooked to raw mode. Prevents
buffered keystrokes from getting lost. Switching back to cooked mode still
flushes.
Fixesjoyent/node#2744.