summaryrefslogtreecommitdiff
path: root/test/parallel/test-vm-sigint-existing-handler.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2016-08-04 23:48:03 +0200
committerAnna Henningsen <anna@addaleax.net>2016-08-08 14:48:01 +0200
commitbe73480eec900604697c43c7664627a286be8ce4 (patch)
tree7a25a5a7a40ccf7b2fa86218bf379d7695b1333c /test/parallel/test-vm-sigint-existing-handler.js
parentb635f7b0e7bf56846750914d15d4869b4530c004 (diff)
downloadandroid-node-v8-be73480eec900604697c43c7664627a286be8ce4.tar.gz
android-node-v8-be73480eec900604697c43c7664627a286be8ce4.tar.bz2
android-node-v8-be73480eec900604697c43c7664627a286be8ce4.zip
test: fix flaky test-vm-sigint-existing-handler
Set the `SIGUSR2` handler before spawning the child process to make sure the signal is always handled. Ref: https://github.com/nodejs/node/pull/7854 Fixes: https://github.com/nodejs/node/issues/7981 PR-URL: https://github.com/nodejs/node/pull/7982 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-vm-sigint-existing-handler.js')
-rw-r--r--test/parallel/test-vm-sigint-existing-handler.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/test/parallel/test-vm-sigint-existing-handler.js b/test/parallel/test-vm-sigint-existing-handler.js
index 0f86b53dd2..c0ab1f8d92 100644
--- a/test/parallel/test-vm-sigint-existing-handler.js
+++ b/test/parallel/test-vm-sigint-existing-handler.js
@@ -61,16 +61,19 @@ if (process.argv[2] === 'child') {
}
process.env.REPL_TEST_PPID = process.pid;
-const child = spawn(process.execPath, [ __filename, 'child' ], {
- stdio: [null, 'inherit', 'inherit']
-});
+// Set the `SIGUSR2` handler before spawning the child process to make sure
+// the signal is always handled.
process.on('SIGUSR2', common.mustCall(() => {
// First kill() breaks the while(true) loop, second one invokes the real
// signal handlers.
process.kill(child.pid, 'SIGINT');
}, 3));
+const child = spawn(process.execPath, [__filename, 'child'], {
+ stdio: [null, 'inherit', 'inherit']
+});
+
child.on('close', function(code, signal) {
assert.strictEqual(signal, null);
assert.strictEqual(code, 0);