javascript - NodeJS- get process ID from within shell script exec -
i have nodejs code runs shell script using child_process.exec(). within shell script run program someprogram. pid of someprogram , pass javascript code can later kill specific process child_process.exec() call. possible?
var exec = require('child_process').exec; var pid = {}; exec('. ./script.sh', function(err, stdout, stderr) { console.log(stdout); settimeout(function() { exec('kill ' + pid, function(err, stdout, stderr) { console.log(stdout); }); }, 6000); }); exec('pgrep -f someprogram', function(err, stdout, stderr) { console.log('stdout' + stdout); pid = stdout; console.log('pid ' + pid); }); just note bottom exec run concurrently. use in gulpfile, etc.
Comments
Post a Comment