Page MenuHomeFreeBSD

Add _Fork()
ClosedPublic

Authored by kib on Aug 2 2021, 9:57 AM.
Tags
None
Referenced Files
F102806699: D31378.diff
Sun, Nov 17, 10:40 AM
Unknown Object (File)
Tue, Nov 5, 4:36 AM
Unknown Object (File)
Fri, Oct 25, 12:56 AM
Unknown Object (File)
Oct 16 2024, 11:27 PM
Unknown Object (File)
Oct 1 2024, 3:02 PM
Unknown Object (File)
Sep 23 2024, 10:41 AM
Unknown Object (File)
Sep 11 2024, 2:23 PM
Unknown Object (File)
Sep 10 2024, 10:41 PM
Subscribers
None

Details

Summary

Current POSIX standard requires fork() to be async-signal safe. Neither our implementation, nor implementations in other operating systems are, and practically it is impossible to make fork() async-signal safe without too much efforts. Also, that could put undue requirement that all atfork handlers should be async-signal safe as well, which contradicts its main use.

As result, Austin Group dropped the requirement, and added a new function _Fork() that should be async-signal safe, but it does not call atfork handlers. Basically, _Fork() can be implemented as a raw syscall.

Release of glibc 2.34 added _Fork(), do the same for FreeBSD. Clarify threading behavior for fork() in the manpage.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Aug 2 2021, 9:57 AM
kib created this revision.
lib/libc/sys/fork.2
82
86
101

".Fx's implementation", or "The .Fx implementation"

116
128
137

Does it effectively mean that LD_BIND_NOW must be set if the child performs cross-DSO calls? It might be worth explaining this a bit further.

246
247
kib marked 8 inline comments as done.

Handle Mark' feedback.

Problems with malloc and rtld in child only happen when forking from mt parent.

markj added inline comments.
lib/libc/sys/fork.2
106
140
This revision is now accepted and ready to land.Aug 3 2021, 1:04 PM
kib marked 2 inline comments as done.Aug 3 2021, 2:41 PM
This revision was automatically updated to reflect the committed changes.
kib added a commit: rG2d319ebe5c08: Style.