File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -640,14 +640,20 @@ void ResetStdio() {
640
640
}
641
641
642
642
if (s.isatty ) {
643
+ sigset_t sa;
643
644
int err;
645
+
646
+ // We might be a background job that doesn't own the TTY so block SIGTTOU
647
+ // before making the tcsetattr() call, otherwise that signal suspends us.
648
+ sigemptyset (&sa);
649
+ sigaddset (&sa, SIGTTOU);
650
+
651
+ CHECK_EQ (0 , pthread_sigmask (SIG_BLOCK, &sa, nullptr ));
644
652
do
645
653
err = tcsetattr (fd, TCSANOW, &s.termios );
646
654
while (err == -1 && errno == EINTR); // NOLINT
647
- // EIO has been observed to be returned by the Linux kernel under some
648
- // circumstances. Reading through drivers/tty/tty_io*.c, it seems to
649
- // indicate the tty went away. Of course none of this is documented.
650
- CHECK_IMPLIES (err == -1 , errno == EIO);
655
+ CHECK_EQ (0 , pthread_sigmask (SIG_UNBLOCK, &sa, nullptr ));
656
+ CHECK_EQ (0 , err);
651
657
}
652
658
}
653
659
#endif // __POSIX__
You can’t perform that action at this time.
0 commit comments