Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

kill all children of a monitored process.

  • Loading branch information...
commit a83a1e19438e65617694f703b21c5248a8304929 1 parent 89be252
@dominictarr dominictarr authored committed
Showing with 9 additions and 2 deletions.
  1. +8 −2 lib/forever/monitor.js
  2. +1 −0  package.json
View
10 lib/forever/monitor.js
@@ -14,6 +14,7 @@ var util = require('util'),
winston = require('winston'),
watch = require('watch'),
minimatch = require('minimatch'),
+ psTree = require('ps-tree'),
forever = require('../forever');
//
@@ -372,9 +373,14 @@ Monitor.prototype.kill = function (forceStop) {
if (forceStop) {
this.forceStop = true;
}
+ psTree(this.child.pid, function (err, children) {
+ var pids = children.map(function (p) { return p.PID })
+ pids.shift(self.child.pid)
+ spawn('kill', ['-9'].concat(pids)).on('exit', function () {
+ self.emit('stop', self.childData);
+ })
+ })
- this.child.kill();
- this.emit('stop', this.childData);
}
return this;
View
1  package.json
@@ -40,6 +40,7 @@
"timespan": "2.0.x",
"watch": "0.3.x",
"minimatch": "0.0.x",
+ "ps-tree": "0.0.x",
"winston": "0.5.x"
},
"devDependencies": {
Please sign in to comment.
Something went wrong with that request. Please try again.