diff options
author | Yihong Wang <yh.wang@ibm.com> | 2018-03-07 23:25:26 +0300 |
---|---|---|
committer | Yihong Wang <yh.wang@ibm.com> | 2018-03-13 02:56:04 +0300 |
commit | ffd618bd5cde77e19ab6458eaf454c4df71dd638 (patch) | |
tree | ce3ac6ceb25fcb8818764856d02f5407137bcb4d /src/node_main.cc | |
parent | 0acdd8402614ce39a95a798b7e2898972332c4c7 (diff) |
test: shared lib build doesn't handle SIGPIPE
For shared lib build, we leave the signal handling for embedding users.
In these two test cases:
- `parallel/test-process-external-stdio-close-spawn`
- `parallel/test-process-external-stdio-close`
The pipe is used for stdout and is destroied before child process uses
it for logging. So the node executble that uses shared lib build
receives SIGPIPE and the child process ends.
This change ignores the SIGPIPE in node_main.cc for shared lib case.
Refs: https://github.com/nodejs/node/issues/18535
Signed-off-by: Yihong Wang <yh.wang@ibm.com>
PR-URL: https://github.com/nodejs/node/pull/19211
Refs: https://github.com/nodejs/node/issues/18535
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'src/node_main.cc')
-rw-r--r-- | src/node_main.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/node_main.cc b/src/node_main.cc index 7ab612d53e5..8907c47ae0e 100644 --- a/src/node_main.cc +++ b/src/node_main.cc @@ -82,12 +82,30 @@ int wmain(int argc, wchar_t *wargv[]) { #endif // __LP64__ extern char** environ; #endif // __linux__ +#if defined(__POSIX__) && defined(NODE_SHARED_MODE) +#include <string.h> +#include <signal.h> +#endif namespace node { extern bool linux_at_secure; } // namespace node int main(int argc, char *argv[]) { +#if defined(__POSIX__) && defined(NODE_SHARED_MODE) + // In node::PlatformInit(), we squash all signal handlers for non-shared lib + // build. In order to run test cases against shared lib build, we also need + // to do the same thing for shared lib build here, but only for SIGPIPE for + // now. If node::PlatformInit() is moved to here, then this section could be + // removed. + { + struct sigaction act; + memset(&act, 0, sizeof(act)); + act.sa_handler = SIG_IGN; + sigaction(SIGPIPE, &act, nullptr); + } +#endif + #if defined(__linux__) char** envp = environ; while (*envp++ != nullptr) {} |