News for hackers. Stuff that matters.
Re:Fork() without exec() is dangerous in large programs (2016) by tuxoko on Tuesday June 14, 2022 @12:50PM (#31742208)
The suggestions here aren't really great. What you should do is already written in the fork(2) manpage https://man7.org/linux/man-pages/man2/fork.2.html

"After a fork() in a multithreaded program, the child can safely call only async-signal-safe functions (see signal-safety(7)) until such time as it calls execve(2)."

So just use only async-singal-safe function https://man7.org/linux/man-pages/man7/signal-safety.7.html

I don't know why so many people still hit this issue when it already told you what you can do and not do in the document. I've done this sort of things without any issue.

Re:Fork() without exec() is dangerous in large programs (2016) by the_mitsuhiko on Tuesday June 14, 2022 @01:08PM (#31742538)
Because in practice it’s almost impossible to know if you are single threaded still. Plenty of system libraries have background threads.
Re:Fork() without exec() is dangerous in large programs (2016) by emmelaich on Tuesday June 14, 2022 @07:49PM (#31747472)
Not to disbelieve you but which ones?
Re:Fork() without exec() is dangerous in large programs (2016) by astrange on Tuesday June 14, 2022 @07:52PM (#31747502)
There are many languages where it's difficult to impossible to be async-signal-safe because you can't avoid memory allocations.