Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upsrc: restore stdio on program exit #20592
Conversation
nodejs-github-bot
added
the
C++
label
May 8, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
looks really promising, let us see how the CI responds. |
This comment has been minimized.
This comment has been minimized.
|
2 failures, one on freebsd:
and one on arm:
Does anyone know if this could be related to the PR? |
jasnell
requested a review
from
bnoordhuis
May 8, 2018
This comment has been minimized.
This comment has been minimized.
|
Is it possible/worthwhile to write at least a minimal test for this behavior? |
This comment has been minimized.
This comment has been minimized.
|
@gireeshpunathil The first error has been seen in CI before: #18658 The second one is new to me. Let's see what happens if we re-run CI: |
This comment has been minimized.
This comment has been minimized.
|
thanks @Trott - those 2 failures are vanished and new ones appear, so safe to assume these are unrelated flaky stuff. @tabkrz - #18446 and #14752 have minimal test cases to reproduce the issue, please see if you can develop them into fully-blown tests. A rough sketch would be:
Please refer to test/parallel/test-child-process-spawn* test cases for general structure, spawn logic, validation logic etc. |
This comment has been minimized.
This comment has been minimized.
|
I will check. |
addaleax
approved these changes
May 9, 2018
My intuition would be “no”, but we should probably not land this PR without a fully green CI. Next attempt: https://ci.nodejs.org/job/node-test-commit/18334/ |
This comment has been minimized.
This comment has been minimized.
|
interesting to see every time we run a new CI, the failure count increases, linearly! btw what is |
This comment has been minimized.
This comment has been minimized.
|
Just took some problematic CI nodes offline. Let's try again... |
This comment has been minimized.
This comment has been minimized.
|
barring the unknown 13:54:49 make[1]: *** [Makefile:87: node] Terminated
13:54:49 make: *** [Makefile:465: build-ci] Terminated
13:54:49 FATAL: command execution failed
13:54:49 java.nio.channels.ClosedChannelException
13:54:49 at org.jenkinsci.remoting.protocol.NetworkLayer.onRecvClosed(NetworkLayer.java:154)
13:54:49 at org.jenkinsci.remoting.protocol.impl.NIONetworkLayer.ready(NIONetworkLayer.java:142)
13:54:49 at org.jenkinsci.remoting.protocol.IOHub$OnReady.run(IOHub.java:789)
13:54:49 at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
13:54:49 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
13:54:49 at |
This comment has been minimized.
This comment has been minimized.
tabkrz
force-pushed the
tabkrz:fix_restore_stdio
branch
3 times, most recently
from
76874f2
to
ffe84ae
May 11, 2018
This comment has been minimized.
This comment has been minimized.
|
@bnoordhuis, please check if current form of PR is sufficient to you. |
tabkrz
force-pushed the
tabkrz:fix_restore_stdio
branch
from
ffe84ae
to
01bea03
May 11, 2018
bnoordhuis
reviewed
May 11, 2018
|
@tabkrz Yes, it's fine now. Left some comments on the second commit. |
| @@ -3313,7 +3313,6 @@ void SetupProcessObject(Environment* env, | |||
|
|
|||
|
|
|||
| void SignalExit(int signo) { | |||
|
|
|||
This comment has been minimized.
This comment has been minimized.
| @@ -4202,17 +4201,19 @@ inline void PlatformInit() { | |||
|
|
|||
| s.flags = GetFileDescriptorFlags(fd); | |||
| CHECK_NE(s.flags, -1); | |||
|
|
|||
| if (isatty(fd)) { | |||
This comment has been minimized.
This comment has been minimized.
bnoordhuis
May 11, 2018
Member
You could just if (isatty(fd)) continue; - saves a level of indent and makes the diff less noisy.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| // tcgetattr() is not supposed to return ENODEV or EOPNOTSUPP | ||
| // but it does so anyway on MacOS. | ||
| CHECK(errno == ENODEV || errno == ENOTTY || errno == EOPNOTSUPP); | ||
| } |
This comment has been minimized.
This comment has been minimized.
bnoordhuis
May 11, 2018
Member
This can probably be simplified to just this now:
s.isatty = true;
do {
err = tcgetattr(fd, &s.termios);
} while (err == -1 && errno == EINTR);
CHECK_EQ(err, 0);
tabkrz
force-pushed the
tabkrz:fix_restore_stdio
branch
from
01bea03
to
113dce5
May 11, 2018
jasnell
approved these changes
May 12, 2018
This comment has been minimized.
This comment has been minimized.
|
We never got a clean CI, at the same time the failures were inconclusive. So running once again: |
This comment has been minimized.
This comment has been minimized.
|
all clean. |
gireeshpunathil
added
the
author ready
label
May 15, 2018
This comment has been minimized.
This comment has been minimized.
|
@bnoordhuis @tabkrz would it be fine for you to land this as a single commit that is done by @bnoordhuis and @tabkrz as a co-author? |
This comment has been minimized.
This comment has been minimized.
|
Fine for me. |
gireeshpunathil
referenced this pull request
May 19, 2018
Open
nodejs sometimes leaves stdout/stderr in non-blocking mode #14752
This comment has been minimized.
This comment has been minimized.
|
@tabkrz Could you update the commits to correctly have your github email and name associated with them? If we land these as is then you won't get proper credit for the work. Thanks! (You can see our contributing guide for more info but basically it's this https://help.github.com/articles/setting-your-commit-email-address-in-git/) |
tabkrz commentedMay 8, 2018
•
edited
Record the state of the stdio file descriptors on start-up and restore
them to that state on exit. This should prevent issues where node.js
sometimes leaves stdio in raw or non-blocking mode.
Author of change: @bnoordhuis
Continuation of #17737 as original pull request was closed.
Fixes: #14752
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes