Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2019-07-04 13:11:00 +0300
committerAnna Henningsen <anna@addaleax.net>2019-07-06 21:44:29 +0300
commitb06ce0bf8d6f50dd2666a3a0d117ccd58c76c694 (patch)
tree52be15ed35a6a12fbf644980664989bdb5ca77ab
parent17862fca5f6acfad5941ec651769493310a5c571 (diff)
src: block SIGTTOU before calling tcsetattr()
We might be a background job that doesn't own the TTY so block SIGTTOU before making the tcsetattr() call, otherwise that signal suspends us. This is a better fix than PR #28490 for issue #28479. Fixes: https://github.com/nodejs/node/issues/28530 Fixes: https://github.com/nodejs/node/issues/28479 Refs: https://github.com/nodejs/node/pull/28490 PR-URL: https://github.com/nodejs/node/pull/28535 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
-rw-r--r--src/node.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/node.cc b/src/node.cc
index 9fdef1a2595..371e7c9f029 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -688,14 +688,20 @@ void ResetStdio() {
}
if (s.isatty) {
+ sigset_t sa;
int err;
+
+ // We might be a background job that doesn't own the TTY so block SIGTTOU
+ // before making the tcsetattr() call, otherwise that signal suspends us.
+ sigemptyset(&sa);
+ sigaddset(&sa, SIGTTOU);
+
+ CHECK_EQ(0, pthread_sigmask(SIG_BLOCK, &sa, nullptr));
do
err = tcsetattr(fd, TCSANOW, &s.termios);
while (err == -1 && errno == EINTR); // NOLINT
- // EIO has been observed to be returned by the Linux kernel under some
- // circumstances. Reading through drivers/tty/tty_io*.c, it seems to
- // indicate the tty went away. Of course none of this is documented.
- CHECK_IMPLIES(err == -1, errno == EIO);
+ CHECK_EQ(0, pthread_sigmask(SIG_UNBLOCK, &sa, nullptr));
+ CHECK_EQ(0, err);
}
}
#endif // __POSIX__