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); }