|
@ -29,25 +29,11 @@ var termSignal; |
|
|
var gotStdoutEOF = false; |
|
|
var gotStdoutEOF = false; |
|
|
var gotStderrEOF = false; |
|
|
var gotStderrEOF = false; |
|
|
|
|
|
|
|
|
var ping = "42\n"; |
|
|
|
|
|
|
|
|
|
|
|
var cat = spawn('cat'); |
|
|
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) { |
|
|
cat.stdout.addListener('data', function(chunk) { |
|
|
assert.equal(chunk.toString(), ping); |
|
|
assert.ok(false); |
|
|
cat.kill(); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
cat.stdout.addListener('end', function() { |
|
|
cat.stdout.addListener('end', function() { |
|
@ -67,6 +53,8 @@ cat.addListener('exit', function(code, signal) { |
|
|
termSignal = signal; |
|
|
termSignal = signal; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
cat.kill(); |
|
|
|
|
|
|
|
|
process.addListener('exit', function() { |
|
|
process.addListener('exit', function() { |
|
|
assert.strictEqual(exitCode, null); |
|
|
assert.strictEqual(exitCode, null); |
|
|
assert.strictEqual(termSignal, 'SIGTERM'); |
|
|
assert.strictEqual(termSignal, 'SIGTERM'); |
|
|