-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
fork() support? #4182
Comments
That sounds quite hard to do. A proper fork needs to do special things with file descriptors, the state of execution, etc., all of which are not practical to support in JS. In practice, I've refactored codebases to avoid fork. |
I see. Well I guess I'll have to do similar. The way fork is used in my end is by a 3rd-party lib which does subprocess handling. Looks like Ill have to give this lib a little makeover with emscripten support, using the child_process APIs. Thanks for your insights, though! :) |
The thing that makes this impossible is that the forked processes are supposed to start executing on the next statement after the Emscripten does have pthreads support for Firefox Nightly and Chrome Canary, so if you don't specifically need a subprocess, but a new thread might do, then you could try using that support instead. It will be a while until that support is mature though and browsers are ready to ship. |
Example code: http://timmurphy.org/2014/04/26/using-fork-in-cc-a-minimum-working-example/
Running this with
emcc
currently gets me the message that it can't fork. I know that in theory nodejs doesn't have actual forking support... but is there a chance to implement it via a mix of child_process+longjmp?Kind regards, Ingwie
The text was updated successfully, but these errors were encountered: