There is an old thread Opinions on exposing core node constructors, e.g.
ChildProcess
<https://groups.google.com/forum/#!topic/nodejs-dev/88J3y7Msx3Y>, dedicated
to discussion about exposing the ChildProcess constructor. Currently I
find it by doing `spawn('cmd').constructor` but this seems like a bad
hack. I want a better kill() method that is platform dependent (windows or
linux), and also reaps all of child's children. So my code is as follows,
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) console.error(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) console.error(error);
});
};
spawn = function(command, commandline) {
cp.spawn(command, commandline, {detached: true});
};
}
I don't understand why `require('child_process').ChildProcess` is not
available.
--
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/7ea9fd7a-afcc-46d6-80ad-525520caa499%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.