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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

oracle - Changing start date for system jobs related to automatic statistics collections in 11g -