Are all reentrant functions safe to use after fork()ing in a multithreaded(with pthreads) process?
问题 I'm working on a C++ project which employs pthreads for multithreading, but also needs to fork now and then. I've read warnings scattered in the code that memory allocation should never be done after fork , but I didn't know exactly why before I found this article. I've summarized the points: When the main thread fork s, the other threads may be in the middle of some library function call; fork ing doesn't copy the other threads, making the calls stuck forever; malloc uses global variable,