How to detect if a Node spawned process is still running?

diegoaguilar

I can spawn a 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 I can control it all asycnchronously with .on(close, ...) but is there any other way to control if a process is still alive?

n_rao

spawn('python', ['topic_listener.py','Node.js'].. Return Child process Object. Use topicListener.pid to find unique ID associated with the process if it's alive.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is it possible to modify source binary in linux if any process spawned from that binary is still running?

From Dev

How to replace node.js process with spawned child?

From Dev

How to get the output of a spawned child_process in Node.JS?

From Dev

Shell spawned backgrounded process is still hanging

From Dev

Unable to get output from infinitely running Ruby application spawned from Node child process

From Dev

how to exit Powershell when a process is still running?

From Dev

spawned process in node.js exiting immediately

From Dev

How do I preserve colors in the console when running a script from a spawned child process?

From Dev

How can a process be blocking another process (that it spawned)?

From Dev

How do I detect collision with spawned objects?

From Dev

How do I detect collision with spawned objects?

From Dev

Node Kue and Child Process - get error from spawned process

From Dev

How to check if a forked process is still running from the c program

From Dev

How to make sure that the process is still running so that I can kill it?

From Dev

How to make sure that the process is still running so that I can kill it?

From Dev

How to collect a process outputs (streaming data) while still it's in running

From Dev

Is a process still running after hibernate?

From Dev

Node.js - spawned process is generating error "execvp(): No such file or directory"

From Dev

Node.js can't get output of spawned process

From Dev

Spawned Node (.exe) process doesnt catch stderr messages

From Dev

node.js how to check a process is running by the process name?

From Dev

How to detect if Node's process.stdout is being piped?

From Dev

How to detect if a mocha test is running in node.js?

From Dev

How to detect if script is running in browser or in Node.js?

From Dev

How do I get the pid of a spawned process using pexpect?

From Dev

How to wait on all child (and grandchild etc) process spawned by a script

From Dev

How to get the exit code of spawned process in expect shell script?

From Dev

How to get list of all child process spawned by a script

From Dev

How to wait on all child (and grandchild etc) process spawned by a script

Related Related

  1. 1

    Is it possible to modify source binary in linux if any process spawned from that binary is still running?

  2. 2

    How to replace node.js process with spawned child?

  3. 3

    How to get the output of a spawned child_process in Node.JS?

  4. 4

    Shell spawned backgrounded process is still hanging

  5. 5

    Unable to get output from infinitely running Ruby application spawned from Node child process

  6. 6

    how to exit Powershell when a process is still running?

  7. 7

    spawned process in node.js exiting immediately

  8. 8

    How do I preserve colors in the console when running a script from a spawned child process?

  9. 9

    How can a process be blocking another process (that it spawned)?

  10. 10

    How do I detect collision with spawned objects?

  11. 11

    How do I detect collision with spawned objects?

  12. 12

    Node Kue and Child Process - get error from spawned process

  13. 13

    How to check if a forked process is still running from the c program

  14. 14

    How to make sure that the process is still running so that I can kill it?

  15. 15

    How to make sure that the process is still running so that I can kill it?

  16. 16

    How to collect a process outputs (streaming data) while still it's in running

  17. 17

    Is a process still running after hibernate?

  18. 18

    Node.js - spawned process is generating error "execvp(): No such file or directory"

  19. 19

    Node.js can't get output of spawned process

  20. 20

    Spawned Node (.exe) process doesnt catch stderr messages

  21. 21

    node.js how to check a process is running by the process name?

  22. 22

    How to detect if Node's process.stdout is being piped?

  23. 23

    How to detect if a mocha test is running in node.js?

  24. 24

    How to detect if script is running in browser or in Node.js?

  25. 25

    How do I get the pid of a spawned process using pexpect?

  26. 26

    How to wait on all child (and grandchild etc) process spawned by a script

  27. 27

    How to get the exit code of spawned process in expect shell script?

  28. 28

    How to get list of all child process spawned by a script

  29. 29

    How to wait on all child (and grandchild etc) process spawned by a script

HotTag

Archive