Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Mar 2008 11:05:30 -0400 (EDT)
From:      Daniel Eischen <deischen@freebsd.org>
To:        ticso@cicely.de
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>, "Marko, Shaun" <Shaun.Marko@lodgenet.com>
Subject:   Re: libpthread/fork issue
Message-ID:  <Pine.GSO.4.64.0803091100260.11971@sea.ntplx.net>
In-Reply-To: <20080309140815.GN34311@cicely12.cicely.de>
References:  <87D91DEDB1111C44BBFB9E3E90FF1E6E9553E0@host.lodgenet.com> <Pine.GSO.4.64.0803071104240.1950@sea.ntplx.net> <20080309140815.GN34311@cicely12.cicely.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 9 Mar 2008, Bernd Walter wrote:

> 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?

popen() should work fine - the child just uses close()
and dup2(), followed by an execve().

-- 
DE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.0803091100260.11971>