diff options
author | John Högberg <[email protected]> | 2018-07-03 13:16:33 +0200 |
---|---|---|
committer | John Högberg <[email protected]> | 2018-07-03 14:33:41 +0200 |
commit | 095c832e1d644c85e452527ffae43dce34b5075e (patch) | |
tree | b089d177be43f8c75c1b9610c8fecebb36aa0217 /erts/emulator/sys | |
parent | a09907d56e29b24ded9a34de82bceac7f39021d1 (diff) | |
download | otp-095c832e1d644c85e452527ffae43dce34b5075e.tar.gz otp-095c832e1d644c85e452527ffae43dce34b5075e.tar.bz2 otp-095c832e1d644c85e452527ffae43dce34b5075e.zip |
Use fallback pollset for stdin and friends when using kqueue
This is a hack to make the "noshell" option work; kqueue can poll
these fds but will not report EV_EOF. This may be common to all
all pipes but we have no way to tell whether an fd is a pipe or
not.
Diffstat (limited to 'erts/emulator/sys')
-rw-r--r-- | erts/emulator/sys/common/erl_poll.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/erts/emulator/sys/common/erl_poll.c b/erts/emulator/sys/common/erl_poll.c index 70b5532af9..b4d1575ee5 100644 --- a/erts/emulator/sys/common/erl_poll.c +++ b/erts/emulator/sys/common/erl_poll.c @@ -803,6 +803,23 @@ update_pollset(ErtsPollSet *ps, int fd, ErtsPollOp op, ErtsPollEvents events) struct kevent evts[2]; struct timespec ts = {0, 0}; + if (op == ERTS_POLL_OP_ADD) { + /* This is a hack to make the "noshell" option work; kqueue can poll + * these fds but will not report EV_EOF, so we return NVAL to use the + * fallback instead. + * + * This may be common to all pipes but we have no way to tell whether + * an fd is a pipe or not. */ + switch (fd) { + case STDIN_FILENO: + case STDOUT_FILENO: + case STDERR_FILENO: + return ERTS_POLL_EV_NVAL; + default: + break; + } + } + #if defined(EV_DISPATCH) && !defined(__OpenBSD__) /* If we have EV_DISPATCH we use it, unless we are on OpenBSD as the behavior of EV_EOF seems to be edge triggered there and we need it |