Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Fixed null signal preservation
Browse files Browse the repository at this point in the history
Closes GH-674.
  • Loading branch information
tj authored and ry committed Feb 16, 2011
1 parent 60ad3aa commit 42a3696
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/node.js
Expand Up @@ -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]);
};
};

Expand Down
20 changes: 20 additions & 0 deletions 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);
});

0 comments on commit 42a3696

Please sign in to comment.