Browse Source

Fixed null signal preservation

Closes GH-674.
v0.7.4-release
Tj Holowaychuk 14 years ago
committed by Ryan Dahl
parent
commit
42a369620f
  1. 16
      src/node.js
  2. 20
      test/simple/test-process-kill-null.js

16
src/node.js

@ -194,13 +194,17 @@
};
process.kill = function(pid, sig) {
sig = sig || 'SIGTERM';
if (!startup.lazyConstants()[sig]) {
throw new Error('Unknown signal: ' + sig);
// preserve null signal
if (0 === sig) {
process._kill(pid, 0);
} else {
sig = sig || 'SIGTERM';
if (startup.lazyConstants()[sig]) {
process._kill(pid, startup.lazyConstants()[sig]);
} else {
throw new Error('Unknown signal: ' + sig);
}
}
process._kill(pid, startup.lazyConstants()[sig]);
};
};

20
test/simple/test-process-kill-null.js

@ -0,0 +1,20 @@
var assert = require('assert');
var spawn = require('child_process').spawn;
var cat = spawn('cat');
var called;
process.kill(cat.pid, 0);
cat.stdout.on('data', function(){
called = true;
process.kill(cat.pid, 'SIGKILL');
});
// EPIPE when null sig fails
cat.stdin.write('test');
process.on('exit', function(){
assert.ok(called);
});
Loading…
Cancel
Save