Skip to content

Commit bb28e2b

Browse files
bnoordhuistargos
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 <soyjuanarbol@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
1 parent b94f63b commit bb28e2b

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
@@ -712,9 +712,11 @@ void ResetStdio() {
712712
while (err == -1 && errno == EINTR); // NOLINT
713713
CHECK_EQ(0, pthread_sigmask(SIG_UNBLOCK, &sa, nullptr));
714714

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

0 commit comments

Comments
 (0)