From f0bf2c2a6ba4b115b1c7805f57d518fc515f10a7 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 4 Aug 2016 23:48:03 +0200 Subject: [PATCH 1/3] 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 --- test/parallel/test-vm-sigint-existing-handler.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-vm-sigint-existing-handler.js b/test/parallel/test-vm-sigint-existing-handler.js index 0f86b53dd282be..027a640037b3b9 100644 --- a/test/parallel/test-vm-sigint-existing-handler.js +++ b/test/parallel/test-vm-sigint-existing-handler.js @@ -61,9 +61,6 @@ if (process.argv[2] === 'child') { } process.env.REPL_TEST_PPID = process.pid; -const child = spawn(process.execPath, [ __filename, 'child' ], { - stdio: [null, 'inherit', 'inherit'] -}); process.on('SIGUSR2', common.mustCall(() => { // First kill() breaks the while(true) loop, second one invokes the real @@ -71,6 +68,10 @@ process.on('SIGUSR2', common.mustCall(() => { 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); From 77ce9d23cabfc6ca0e8d1c30c13e51abd779e41e Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 5 Aug 2016 00:03:42 +0200 Subject: [PATCH 2/3] Add code comments explaining the order of spawn()/process.on() --- test/parallel/test-vm-sigint-existing-handler.js | 2 ++ test/parallel/test-vm-sigint.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/test/parallel/test-vm-sigint-existing-handler.js b/test/parallel/test-vm-sigint-existing-handler.js index 027a640037b3b9..954edc0a913343 100644 --- a/test/parallel/test-vm-sigint-existing-handler.js +++ b/test/parallel/test-vm-sigint-existing-handler.js @@ -62,6 +62,8 @@ if (process.argv[2] === 'child') { process.env.REPL_TEST_PPID = process.pid; +// 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. diff --git a/test/parallel/test-vm-sigint.js b/test/parallel/test-vm-sigint.js index 15d61d3232871a..def51a7e746437 100644 --- a/test/parallel/test-vm-sigint.js +++ b/test/parallel/test-vm-sigint.js @@ -25,6 +25,9 @@ if (process.argv[2] === 'child') { } process.env.REPL_TEST_PPID = process.pid; + +// Set the `SIGUSR2` handler before spawning the child process to make sure +// the signal is always handled. process.on('SIGUSR2', common.mustCall(() => { process.kill(child.pid, 'SIGINT'); })); From 055196e524193cfad819fcd49f8721faa5bdc939 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 7 Aug 2016 15:47:05 +0200 Subject: [PATCH 3/3] =?UTF-8?q?fix=20nit=20removing=20whitespace=20inside?= =?UTF-8?q?=20of=20[=20=E2=80=A6=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/parallel/test-vm-sigint-existing-handler.js | 2 +- test/parallel/test-vm-sigint.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-vm-sigint-existing-handler.js b/test/parallel/test-vm-sigint-existing-handler.js index 954edc0a913343..c0ab1f8d92b821 100644 --- a/test/parallel/test-vm-sigint-existing-handler.js +++ b/test/parallel/test-vm-sigint-existing-handler.js @@ -70,7 +70,7 @@ process.on('SIGUSR2', common.mustCall(() => { process.kill(child.pid, 'SIGINT'); }, 3)); -const child = spawn(process.execPath, [ __filename, 'child' ], { +const child = spawn(process.execPath, [__filename, 'child'], { stdio: [null, 'inherit', 'inherit'] }); diff --git a/test/parallel/test-vm-sigint.js b/test/parallel/test-vm-sigint.js index def51a7e746437..8846338b78086c 100644 --- a/test/parallel/test-vm-sigint.js +++ b/test/parallel/test-vm-sigint.js @@ -32,7 +32,7 @@ process.on('SIGUSR2', common.mustCall(() => { process.kill(child.pid, 'SIGINT'); })); -const child = spawn(process.execPath, [ __filename, 'child' ], { +const child = spawn(process.execPath, [__filename, 'child'], { stdio: [null, 'pipe', 'inherit'] });