Having fork('./MyProcess.js',['foo']);
in the main process and console.log(process.argv[2]);
in the forked process will log foo to my console.
However, fork('./MyProcess.js',[{myProp : 'bar'}]);
in the main process and console.log(process.argv[2]); console.log(process.argv[2].myProp);
in the forked process will log [object Object] (as expected) but undefined for the second log.
Why is this, and what should I do to get the desired behavior?
Pass object(json) to child process through commadline arguments is not a good idea, command arguments need escape first(not easy). You have some choice:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With