Page MenuHomeFreeBSD

Add _Fork()

Authored by kib on Aug 2 2021, 9:57 AM.



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

R10 FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kib requested review of this revision.Aug 2 2021, 9:57 AM
kib created this revision.
82 ↗(On Diff #93097)
86 ↗(On Diff #93097)
101 ↗(On Diff #93097)

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

115 ↗(On Diff #93097)
127 ↗(On Diff #93097)
136 ↗(On Diff #93097)

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.

236 ↗(On Diff #93097)
237 ↗(On Diff #93097)
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.
106 ↗(On Diff #93142)
140 ↗(On Diff #93142)
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: R10:2d319ebe5c08: Style.