From 317621b4a12562eb75055a67bb2c5556f53fe017 Mon Sep 17 00:00:00 2001 From: patr0nus Date: Thu, 18 Jun 2020 22:41:56 +0800 Subject: [PATCH] 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. --- src/node.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/node.cc b/src/node.cc index b7435d67f839ea..438b08391dc49c 100644 --- a/src/node.cc +++ b/src/node.cc @@ -737,7 +737,10 @@ void ResetStdio() { err = tcsetattr(fd, TCSANOW, &s.termios); while (err == -1 && errno == EINTR); // NOLINT CHECK_EQ(0, pthread_sigmask(SIG_UNBLOCK, &sa, nullptr)); - CHECK_EQ(0, err); + + // Normally we expect err == 0. But if macOS App Sandbox is enabled, + // tcsetattr will fail with err == -1 and errno == EPERM. + CHECK_IMPLIES(err != 0, err == -1 && errno == EPERM); } } #endif // __POSIX__