0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/simple/test-child-process-kill.js
2010-07-15 14:21:31 -07:00

43 lines
796 B
JavaScript

common = require("../common");
assert = common.assert
var spawn = require('child_process').spawn;
var exitCode;
var termSignal;
var gotStdoutEOF = false;
var gotStderrEOF = false;
var cat = spawn("cat");
cat.stdout.addListener("data", function (chunk) {
assert.ok(false);
});
cat.stdout.addListener("end", function () {
gotStdoutEOF = true;
});
cat.stderr.addListener("data", function (chunk) {
assert.ok(false);
});
cat.stderr.addListener("end", function () {
gotStderrEOF = true;
});
cat.addListener("exit", function (code, signal) {
exitCode = code;
termSignal = signal;
});
cat.kill();
process.addListener("exit", function () {
assert.strictEqual(exitCode, null);
assert.strictEqual(termSignal, 'SIGTERM');
assert.ok(gotStdoutEOF);
assert.ok(gotStderrEOF);
});