Created
June 20, 2012 14:38
-
-
Save squarefeet/2960203 to your computer and use it in GitHub Desktop.
Node PID bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var exec = require('child_process').exec, | |
child = exec('node [PATH-TO-YOUR-KEEP-ALIVE-NODE-FILE]'); | |
console.log('child pid: ' + child.pid); | |
exec('ps aux | grep node', function(err, stdout) { | |
console.log(stdout); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Think this is the cause:
See that
/bin/sh -c ...
line? That's the process thatchild.pid
is reporting back. SIGTERM-ing that process does fuck all. To kill the child process, you need to killnode test.js
, which is another process spawned straight after the exec command.So.. exec creates one process, and 'cos I'm spinning up a new node instance within that exec child proc, it'll have a diff. pid than the exec proc.
Bit of a derp moment :(