[PATCH] Fix possible deadlock in stdio locking code
Jonathan Nieder
jrnieder@gmail.com
Fri Nov 11 14:49:00 GMT 2011
Siddhesh Poyarekar wrote:
> while(1) {
> int child = fork();
>
> if (child == 0)
> exit(0);
POSIX explains (under fork()):
If a multi-threaded process calls fork( ), the new process
shall contain a replica of the calling thread and its entire
address space, possibly including the states of mutexes and
other resources. Consequently, to avoid errors, the child
process may only execute async-signal-safe operations until
such time as one of the exec functions is called.
exit() is not async-signal-safe, though _exit() is. I don't think
that glibc is the right tool to diagnose or work around application
problems like this. (Maybe helgrind could be tweaked to make the
diagnosis.)
More information about the Libc-alpha
mailing list