From d4a44586d226b437f87f5bbb2ea2a3a25dfc8a52 Mon Sep 17 00:00:00 2001 From: Veselin Todorov Date: Thu, 12 Jan 2012 22:02:51 +0200 Subject: [PATCH] Replacing exec(kill) with process.kill. Thanks @visionmedia. --- lib/watcher.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/watcher.js b/lib/watcher.js index fca3116..501ef2e 100644 --- a/lib/watcher.js +++ b/lib/watcher.js @@ -154,9 +154,13 @@ Watcher.prototype.notify = function(pid, state) { */ Watcher.prototype.check = function(pid, cb) { this.parse(pid, function(p) { - exec('kill -0 ' + p, function(error, stdout, stderr) { - cb(!(stderr)); - }); + var result = false; + try { + if (p && !process.kill(p, 0)) result = true; + } catch (err) { + result = false; + } + cb(result); }); };