Skip to content

Commit a793706

Browse files
bnoordhuisaduh95
authored andcommitted
src: remove overzealous tcsetattr error check
Node calls tcsetattr on exit to reset the tty to its state on program start. Good idea in general but tcsetattr can fail for a number of reasons and since there really isn't anything we can do about it at that point, simply ignore the error instead of aborting with an inscrutable error message. Most of the time it'll be fine because the most common failure is when the user has already logged off and there isn't anything to restore in the first place. Fixes: #51519 PR-URL: #58200 Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ethan Arrowood <[email protected]>
1 parent af7baef commit a793706

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/node.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,11 @@ void ResetStdio() {
761761
while (err == -1 && errno == EINTR); // NOLINT
762762
CHECK_EQ(0, pthread_sigmask(SIG_UNBLOCK, &sa, nullptr));
763763

764-
// Normally we expect err == 0. But if macOS App Sandbox is enabled,
765-
// tcsetattr will fail with err == -1 and errno == EPERM.
766-
CHECK_IMPLIES(err != 0, err == -1 && errno == EPERM);
764+
// We don't check the return value of tcsetattr() because it can fail
765+
// for a number of reasons, none that we can do anything about. Examples:
766+
// - if macOS App Sandbox is enabled, tcsetattr fails with EPERM
767+
// - if the process group is orphaned, e.g. because the user logged out,
768+
// tcsetattr fails with EIO
767769
}
768770
}
769771
#endif // __POSIX__

0 commit comments

Comments
 (0)