500 Subj : Re: pthreads and fork To : comp.programming.threads From : Alexander Terekhov Date : Sat Feb 19 2005 06:04 pm Marcin 'Qrczak' Kowalczyk wrote: [...] > The threads are under my control, as are fork calls, and I can > synchronize whatever I need. But in order to implement anything which > calls fork while more than one thread is running, I must know what > happens with resources associated with pthread_t in the child process. Child process shall be an exact copy of the parent process except... (see the spec). No user stuff cleanup (apart from the stuff you may have in atfork() handlers) or any modifications affecting *user's* state (apart from "except...") is done be the implementation. [...] > Experiments on Linux/NPTL show that pthread_join succeeds on these > threads (the exit value of such thread is a null pointer). I want to > know whether I can rely on that You can't. Threads (apart from the cloned one) are gone (abandoned). You have to roll your own registry of resources to cleanup. And also use user-specified thread stacks... But you may still have leaks of resources controlled by the implementation. So "leak-free" in my previous message was partly misleading. Sorry for that. regards, alexander. . 0