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.
"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.