I'm using windows, and I'm doing this experiment,
console.log( _.process.exec( "mongod --dbpath . --port 8083 --bind_ip 127.0.0.1" ).pid );
The problem is, when I do a tasklist command, the PID from that output points to the command prompt task and not to the mongod.exe task.
Is there a way to get the real PID of the mongod.exe task?
That's because mongod is a child process of cmd and tasklist doesn't print child process ids.
Given a parent process id, you can get a list of it's children with a wmi query:
wmic process where (ParentProcessId=CMD_PID) get Caption, ProcessId
Replace CMD_PID with the parent(cmd) process id.
I'm looking at this now and thinking that I'll need to run process.pid in the child and signal it back to the parent. The parent then needs to keep track of the number in case the child needs to be killed.
I was hoping this wouldn't be so complicated?