Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2011-08-04 20:40:41 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2011-08-04 20:40:41 +0400
commit2bbb46842848b8def1188932755054aa808ccbe6 (patch)
tree86057becc103d5837bf46ff135c8bb3e6671cf76 /lib
parentac722bbed6ea846991904ed205a6dc5ece4748c9 (diff)
child process: bind to libuv's kill process API
Fixes failing test test/simple/test-child-process-kill.js
Diffstat (limited to 'lib')
-rw-r--r--lib/child_process_uv.js31
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/child_process_uv.js b/lib/child_process_uv.js
index 6eed97d08ce..00a43a0790d 100644
--- a/lib/child_process_uv.js
+++ b/lib/child_process_uv.js
@@ -22,6 +22,7 @@
var EventEmitter = require('events').EventEmitter;
var Process = process.binding('process_wrap').Process;
var inherits = require('util').inherits;
+var constants; // if (!constants) constants = process.binding('constants');
// constructors for lazy loading
@@ -215,8 +216,17 @@ function ChildProcess() {
this._internal = new Process();
this._internal.onexit = function(exitCode, signalCode) {
- if (signalCode) self.signalCode = signalCode;
- self.exitCode = exitCode;
+ //
+ // follow 0.4.x behaviour:
+ //
+ // - normally terminated processes don't touch this.signalCode
+ // - signaled processes don't touch this.exitCode
+ //
+ if (signalCode) {
+ self.signalCode = signalCode;
+ } else {
+ self.exitCode = exitCode;
+ }
if (self.stdin) {
self.stdin.destroy();
@@ -298,6 +308,7 @@ ChildProcess.prototype.spawn = function(options) {
return r;
};
+
function errnoException(errorno, syscall) {
// TODO make this more compatible with ErrnoException from src/node.cc
// Once all of Node is using this function the ErrnoException from
@@ -310,5 +321,19 @@ function errnoException(errorno, syscall) {
ChildProcess.prototype.kill = function(sig) {
- throw new Error("implement me");
+ if (!constants) {
+ constants = process.binding('constants');
+ }
+
+ sig = sig || 'SIGTERM';
+ var signal = constants[sig];
+
+ if (!signal) {
+ throw new Error('Unknown signal: ' + sig);
+ }
+
+ if (!this.signalCode && !this.exitCode) {
+ var r = this._internal.kill(signal);
+ // TODO: raise error if r == -1?
+ }
};