Skip to content

Commit eaf474c

Browse files
yhwangBethGriggs
authored andcommittedMar 21, 2019
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: #18535 Signed-off-by: Yihong Wang <yh.wang@ibm.com> PR-URL: #19211 Refs: #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> Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
1 parent 3128cb7 commit eaf474c

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed
 

‎node.gyp

+3-17
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@
178178
'sources': [
179179
'src/node_main.cc'
180180
],
181+
'includes': [
182+
'node.gypi'
183+
],
181184
'include_dirs': [
182185
'src',
183186
'deps/v8/include',
@@ -195,9 +198,6 @@
195198
}],
196199
[ 'node_intermediate_lib_type=="static_library" and '
197200
'node_shared=="false"', {
198-
'includes': [
199-
'node.gypi'
200-
],
201201
'xcode_settings': {
202202
'OTHER_LDFLAGS': [
203203
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)'
@@ -439,22 +439,8 @@
439439
],
440440
}],
441441
],
442-
'defines!': [
443-
'NODE_PLATFORM="win"',
444-
],
445-
'defines': [
446-
'FD_SETSIZE=1024',
447-
# we need to use node's preferred "win32" rather than gyp's preferred "win"
448-
'NODE_PLATFORM="win32"',
449-
# Stop <windows.h> from defining macros that conflict with
450-
# std::min() and std::max(). We don't use <windows.h> (much)
451-
# but we still inherit it from uv.h.
452-
'NOMINMAX',
453-
'_UNICODE=1',
454-
],
455442
'libraries': [ '-lpsapi.lib' ]
456443
}, { # POSIX
457-
'defines': [ '__POSIX__' ],
458444
'sources': [ 'src/backtrace_posix.cc' ],
459445
}],
460446
[ 'node_use_etw=="true"', {

‎node.gypi

+18
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@
3737
'NODE_SHARED_MODE',
3838
],
3939
}],
40+
[ 'OS=="win"', {
41+
'defines!': [
42+
'NODE_PLATFORM="win"',
43+
],
44+
'defines': [
45+
'FD_SETSIZE=1024',
46+
# we need to use node's preferred "win32" rather than gyp's preferred "win"
47+
'NODE_PLATFORM="win32"',
48+
# Stop <windows.h> from defining macros that conflict with
49+
# std::min() and std::max(). We don't use <windows.h> (much)
50+
# but we still inherit it from uv.h.
51+
'NOMINMAX',
52+
'_UNICODE=1',
53+
],
54+
}, { # POSIX
55+
'defines': [ '__POSIX__' ],
56+
}],
57+
4058
[ 'node_enable_d8=="true"', {
4159
'dependencies': [ 'deps/v8/src/d8.gyp:d8' ],
4260
}],

‎src/node_main.cc

+18
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,30 @@ int wmain(int argc, wchar_t *wargv[]) {
8282
#endif // __LP64__
8383
extern char** environ;
8484
#endif // __linux__
85+
#if defined(__POSIX__) && defined(NODE_SHARED_MODE)
86+
#include <string.h>
87+
#include <signal.h>
88+
#endif
8589

8690
namespace node {
8791
extern bool linux_at_secure;
8892
} // namespace node
8993

9094
int main(int argc, char *argv[]) {
95+
#if defined(__POSIX__) && defined(NODE_SHARED_MODE)
96+
// In node::PlatformInit(), we squash all signal handlers for non-shared lib
97+
// build. In order to run test cases against shared lib build, we also need
98+
// to do the same thing for shared lib build here, but only for SIGPIPE for
99+
// now. If node::PlatformInit() is moved to here, then this section could be
100+
// removed.
101+
{
102+
struct sigaction act;
103+
memset(&act, 0, sizeof(act));
104+
act.sa_handler = SIG_IGN;
105+
sigaction(SIGPIPE, &act, nullptr);
106+
}
107+
#endif
108+
91109
#if defined(__linux__)
92110
char** envp = environ;
93111
while (*envp++ != nullptr) {}

0 commit comments

Comments
 (0)
Please sign in to comment.