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

Commit

Permalink
make process.kill a no-op on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zinkovsky authored and ry committed Oct 21, 2011
1 parent fafb584 commit 69b73f9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
32 changes: 21 additions & 11 deletions src/node.js
Expand Up @@ -321,24 +321,34 @@
};

startup.processKillAndExit = function() {
var isWindows = process.platform === 'win32';

process.exit = function(code) {
process.emit('exit', code || 0);
process.reallyExit(code || 0);
};

process.kill = function(pid, 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]);
if (isWindows) {
process.kill = function(pid, sig) {
console.warn('process.kill() is not supported on Windows. Use ' +
'child.kill() to kill a process that was started ' +
'with child_process.spawn().');
}
} else {
process.kill = function(pid, sig) {
// preserve null signal
if (0 === sig) {
process._kill(pid, 0);
} else {
throw new Error('Unknown signal: ' + sig);
sig = sig || 'SIGTERM';
if (startup.lazyConstants()[sig]) {
process._kill(pid, startup.lazyConstants()[sig]);
} else {
throw new Error('Unknown signal: ' + sig);
}
}
}
};
};
}
};

startup.processSignalHandlers = function() {
Expand Down
6 changes: 4 additions & 2 deletions test/simple/test-process-kill-null.js
Expand Up @@ -19,8 +19,10 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

// libuv-broken

if (process.platform === 'win32') {
console.warn('Skipping because process.kill is not supported on windows');
process.exit(0);
}


var assert = require('assert');
Expand Down

0 comments on commit 69b73f9

Please sign in to comment.