summaryrefslogtreecommitdiff
path: root/src/node.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/node.cc')
-rw-r--r--src/node.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/node.cc b/src/node.cc
index 9fdef1a259..371e7c9f02 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__