File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -688,14 +688,20 @@ void ResetStdio() {
688
688
}
689
689
690
690
if (s.isatty ) {
691
+ sigset_t sa;
691
692
int err;
693
+
694
+ // We might be a background job that doesn't own the TTY so block SIGTTOU
695
+ // before making the tcsetattr() call, otherwise that signal suspends us.
696
+ sigemptyset (&sa);
697
+ sigaddset (&sa, SIGTTOU);
698
+
699
+ CHECK_EQ (0 , pthread_sigmask (SIG_BLOCK, &sa, nullptr ));
692
700
do
693
701
err = tcsetattr (fd, TCSANOW, &s.termios );
694
702
while (err == -1 && errno == EINTR); // NOLINT
695
- // EIO has been observed to be returned by the Linux kernel under some
696
- // circumstances. Reading through drivers/tty/tty_io*.c, it seems to
697
- // indicate the tty went away. Of course none of this is documented.
698
- CHECK_IMPLIES (err == -1 , errno == EIO);
703
+ CHECK_EQ (0 , pthread_sigmask (SIG_UNBLOCK, &sa, nullptr ));
704
+ CHECK_EQ (0 , err);
699
705
}
700
706
}
701
707
#endif // __POSIX__
You can’t perform that action at this time.
0 commit comments