Skip to content

Commit be20914

Browse files
yhwangMylesBorins
authored andcommitted
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 <[email protected]> PR-URL: #19211 Refs: #18535 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent 66694e2 commit be20914

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
@@ -194,6 +194,9 @@
194194
'sources': [
195195
'src/node_main.cc'
196196
],
197+
'includes': [
198+
'node.gypi'
199+
],
197200
'include_dirs': [
198201
'src',
199202
'deps/v8/include',
@@ -211,9 +214,6 @@
211214
}],
212215
[ 'node_intermediate_lib_type=="static_library" and '
213216
'node_shared=="false"', {
214-
'includes': [
215-
'node.gypi'
216-
],
217217
'xcode_settings': {
218218
'OTHER_LDFLAGS': [
219219
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)'
@@ -455,22 +455,8 @@
455455
],
456456
}],
457457
],
458-
'defines!': [
459-
'NODE_PLATFORM="win"',
460-
],
461-
'defines': [
462-
'FD_SETSIZE=1024',
463-
# we need to use node's preferred "win32" rather than gyp's preferred "win"
464-
'NODE_PLATFORM="win32"',
465-
# Stop <windows.h> from defining macros that conflict with
466-
# std::min() and std::max(). We don't use <windows.h> (much)
467-
# but we still inherit it from uv.h.
468-
'NOMINMAX',
469-
'_UNICODE=1',
470-
],
471458
'libraries': [ '-lpsapi.lib' ]
472459
}, { # POSIX
473-
'defines': [ '__POSIX__' ],
474460
'sources': [ 'src/backtrace_posix.cc' ],
475461
}],
476462
[ '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)