-
Notifications
You must be signed in to change notification settings - Fork 689
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
Rethinking the interface for fork
#586
Comments
fork
fork
Also see http://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them And the man page says:
This makes it sound like |
This has come up in the standard library, too: rust-lang/rust#39575 |
You're right that |
@asomers I read through some of the discussion there. The argument is that UB should be assumed to include memory unsafety by default. Specifically for |
Is there any undefined behavior associated with calling async-signal-unsafe functions after forking? I can't find any. fork(2) doesn't mention any undefined behavior. Instead, it suggests not calling async-signal-unsafe functions in order to prevent deadlocks and the like. |
@jonas-schievink @asomers Did this get cleaned resolved with the merging of #695? |
This comment has been minimized.
This comment has been minimized.
Update: The conclusion of rust-lang/rust#39575 was that |
@jonas-schievink thanks for that update! |
The rustdocs for |
PR #2591 will fix this |
I was writing a shell as an example for nix, and I realised that #555 makes a really good point: the code that runs in the child after
fork(2)
must not allocate if there is more than one thread. I don't know iffork
should necessarily be made unsafe, but certainly we need to document better what is ok to do afterwards.This is somewhat related to #90 in that there's an execution context where only limited operations should be performed. Ideally nix would force only correct usage, but at the same time there's a lot of value of staying close to the libc definitions of functions. (#190 seems connected here too.)
The text was updated successfully, but these errors were encountered: