javascript - How to tell if child Node.js Process was from fork() or not? -
i have small application executed fork or directly developer, , configured differently depending on how started.
i know pass in arguments to signal fork, curious if there way tell if somehow know in child process if came fork()
. looked around in process
didn't find telling.
it's bit of hack, can check if process.send
exists in application. when started using fork()
exist.
if (process.send === undefined) { console.log('started directly'); } else { console.log('started fork()'); }
personally, set environment variable in parent , check in child:
// parent.js child_process.fork('./child', { env : { fork : 1 } }); // child.js if (process.env.fork) { console.log('started fork()'); }
Comments
Post a Comment