Subj : Re: Issues with multi-threading and fork To : comp.programming.threads From : loic-dev Date : Thu Mar 31 2005 05:44 am Salut Jerome, > busy-wait for the child process to terminate by the means of: > > cnt = timeout; > while (waitpid (pid , &status, WNOHANG) == 0 && cnt != 0) > { > sleep (1); > --cnt; > } > > (I didn't find any other way to implement timeouted waitpid in > a mutil-threaded context since one cannot use signals) Why? Ok with LinuxThreads things are not so easy. But in your case, the signal would be delivered to the thread that forked the child (POSIX states that the SIGCHLD is delivered to any thread that has that signal unblocked). >> From time to times, the timeout mysteriously expires, so I searched > for the causes. > > After some investigation, it seems that the child process hangs right > after the fork and does not go further. [snip] > Any idea about what might be happening? Hmmm... difficult to say what's wrong... Perhaps an issue in LinuxThreads? The best thing would be to post a stripped example that still shows your issue. We could then make some deeper investigations. Cheers, Loic. .