From 69b73f9cf0df80fe177f45cebe6a94ee16466245 Mon Sep 17 00:00:00 2001 From: Igor Zinkovsky Date: Fri, 21 Oct 2011 09:08:19 -0700 Subject: [PATCH] make process.kill a no-op on windows --- src/node.js | 32 +++++++++++++++++++++----------- test/simple/test-process-kill-null.js | 6 ++++-- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/node.js b/src/node.js index fddf320..2214a8b 100644 --- a/src/node.js +++ b/src/node.js @@ -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() { diff --git a/test/simple/test-process-kill-null.js b/test/simple/test-process-kill-null.js index 54caca2..1b9ba17 100644 --- a/test/simple/test-process-kill-null.js +++ b/test/simple/test-process-kill-null.js @@ -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'); -- 2.7.4