node.js - How to detect if a Node spawned process is still running? -


i can spawn process like:

var spawn = require('child_process').spawn;  var topiclistener = spawn('python', ['topic_listener.py','node.js'], {env: {     twitter_consumer_secret: process.env.twitter_consumer_secret,     twitter_consumer_key: process.env.twitter_consumer_key,     twitter_token_secret: process.env.twitter_token_secret,     twitter_access_token: process.env.twitter_access_token }});  topiclistener.stdout.on('data', function (data) {     console.log(data.tostring()); });  topiclistener.stderr.on('data', function (data) {     console.log(data.tostring()); });  topiclistener.on('close', function (code) {     console.log("exited " + code); }); 

so of course can control asycnchronously .on(close, ...) there other way control if process still alive?

spawn('python', ['topic_listener.py','node.js'].. return child process object. use topiclistener.pid find unique id associated process if it's alive.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -