Skip to content

Commit 317621b

Browse files
committed
src: tolerate EPERM returned from tcsetattr
macOS app sandbox makes tcsetattr return EPERM. The CHECK_EQ(0, err) here would fail when a sandboxed Node.js process is exiting. This commit fixes this issue.
1 parent a4f3206 commit 317621b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/node.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,10 @@ void ResetStdio() {
737737
err = tcsetattr(fd, TCSANOW, &s.termios);
738738
while (err == -1 && errno == EINTR); // NOLINT
739739
CHECK_EQ(0, pthread_sigmask(SIG_UNBLOCK, &sa, nullptr));
740-
CHECK_EQ(0, err);
740+
741+
// Normally we expect err == 0. But if macOS App Sandbox is enabled,
742+
// tcsetattr will fail with err == -1 and errno == EPERM.
743+
CHECK_IMPLIES(err != 0, err == -1 && errno == EPERM);
741744
}
742745
}
743746
#endif // __POSIX__

0 commit comments

Comments
 (0)