libpthread/fork issue

Bernd Walter ticso at
Sun Mar 9 14:08:29 UTC 2008

On Fri, Mar 07, 2008 at 11:08:50AM -0500, Daniel Eischen wrote:
> On Thu, 6 Mar 2008, Marko, Shaun wrote:
> >I'm working on FreeBSD 6.2 and I'm wondering if anybody can help with an
> >issue I've found using fork and threads. The attached program
> >demonstrates the problem. In short, if a process creates a thread, joins
> >the thread, then forks a child process which creates a thread, the
> >child's attempt to create a thread will cause the program to dump core
> >with the following error message:
> >Fatal error 'mutex is on list' at line 540 in file
> >/usr/src/lib/libpthread/thread/thr_mutex.c (errno = 0).
> You are not allowed by POSIX to call any non-async-signal-safe
> function from a child of a threaded program.  There's words
> or rationale to the effect that the only purpose for forking
> from a threaded program should be to call one of the exec*
> functions.  Trying to create a thread from a child (like
> you are trying to do) is definitely not supported.

I've often done it, but since this is subject right now it is a good
point to ask if I just had luck so far.
Is it allowed to use popen(3) from a threaded programm?

bernd at           info at            support at

More information about the freebsd-hackers mailing list