diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2011-08-03 18:05:49 +0400 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2011-08-03 18:05:49 +0400 |
commit | 12c8b27e243724a40128b6e335713edc63993d5a (patch) | |
tree | 8d39fc7831df555a04f07de33978e2c4c98ee13e /test | |
parent | 09bb1d64dc774bc52f1b0dfd048715ad3243e550 (diff) |
test: fix exec-after-fork race in test/simple/test-child-process-kill.js
Diffstat (limited to 'test')
-rw-r--r-- | test/simple/test-child-process-kill.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/test/simple/test-child-process-kill.js b/test/simple/test-child-process-kill.js index 65d858a8647..116e91c5efa 100644 --- a/test/simple/test-child-process-kill.js +++ b/test/simple/test-child-process-kill.js @@ -29,11 +29,25 @@ var termSignal; var gotStdoutEOF = false; var gotStderrEOF = false; +var ping = "42\n"; + var cat = spawn('cat'); +// +// This test sends a signal to a child process. +// +// There is a potential race here where the signal is delivered +// after the fork() but before execve(). IOW, the signal is sent +// before the child process has truly been started. +// +// So we wait for a sign of life from the child (the ping response) +// before sending the signal. +// +cat.stdin.write(ping); cat.stdout.addListener('data', function(chunk) { - assert.ok(false); + assert.equal(chunk.toString(), ping); + cat.kill(); }); cat.stdout.addListener('end', function() { @@ -53,8 +67,6 @@ cat.addListener('exit', function(code, signal) { termSignal = signal; }); -cat.kill(); - process.addListener('exit', function() { assert.strictEqual(exitCode, null); assert.strictEqual(termSignal, 'SIGTERM'); |