From bfdc421ddadd35b2ea5de07a756a52b881c7a981 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 20 Mar 2010 03:01:17 -0700 Subject: [PATCH] Don't kill negative PIDs Fixes issue GH-79. --- src/node_child_process.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/node_child_process.cc b/src/node_child_process.cc index 870269f5fd..c1f6237c8e 100644 --- a/src/node_child_process.cc +++ b/src/node_child_process.cc @@ -129,6 +129,10 @@ Handle ChildProcess::Kill(const Arguments& args) { ChildProcess *child = ObjectWrap::Unwrap(args.Holder()); assert(child); + if (child->pid_ < 1) { + return ThrowException(Exception::Error(String::New("No such process"))); + } + int sig = SIGTERM; if (args.Length() > 0) { @@ -266,6 +270,7 @@ void ChildProcess::OnExit(int code) { int ChildProcess::Kill(int sig) { + if (pid_ > 0) return -1; return kill(pid_, sig); }