Page MenuHomeFreeBSD

Add _Fork()
ClosedPublic

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

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
R10 FreeBSD src repository
Lint
Lint Skipped
Unit
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"

115
127
136

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
237
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
105
138
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.