I would like to make it so that ChildProcess.prototype.kill() reaps all
children and is platform independent. However I cannot seem to find access
to the ChildProcess constructor without actually instantiating it.
Require('child_process') gives only helper constructors like spawn and
exec, not actual constructors. Is there something I am missing here?
cp = require('child_process')
switch (process.platform) {
case 'win32':
ChildProcess = cp.spawn('cmd').constructor;
ChildProcess.prototype.kill = function() {
cp.exec("taskkill /F /T /PID " + this.pid, function(error, stdout,
stderr) {
if (error) {
throw error;
}
});
};
spawn = function(command, commandline) {
cp.spawn('cmd', ['/C', command].concat(commandline));
};
break;
default:
ChildProcess = cp.spawn('ls').constructor;
ChildProcess.prototype.kill = function() {
cp.exec("kill -TERM -" + this.pid, function(error, stdout, stderr) {
if (error) {
throw error;
}
});
spawn = function(command, commandline) {
cp.spawn(command, commandline, {
detach: true
});
};
};
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/3ba5d6a6-cabf-4270-ae4b-52b9094b343c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.