-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
child_process.fork() workaround for windows #1516
Comments
Thanks for sharing. |
I am very new to node, and here's my code. My code is crashing with exit code 8 for some reason that I can't figure out. Can you please help? I am using Windows, right now. processor.js:
processor_fork.js:
|
@rogerwang Do you know what I am doing wrong in the above code? Can I do this some other way? |
@kraag22 You saved my life, thank you so much! |
What about Linux? fork doesn't work on Linux either. |
Thanks a lot !! This is amazing |
Thanks a lot !! |
If you want to use child_process.fork() you cannot, because of issue #213
But if specify your own node executable in the options like this
var processing = ch.fork('c:\\reader.js', [], {execPath: 'c:\\node.exe'})
you can use it. There is no problem running on mac, but in windows you forked node will crash if there is any stdio operation. Child process will crash with exit code 8.
So example code:
This code will fail on windows when the reader.js prints anything in the console for us. The workaround is adding silent:true to fork() options.
var processing = ch.fork('c:\\reader.js', [], {execPath: 'c:\\node.exe', silent: true})
I hope this will save some time to anyone experiencing this problem.
The text was updated successfully, but these errors were encountered: