From owner-freebsd-hackers@FreeBSD.ORG Sun Mar 9 15:05:35 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B7571065670 for ; Sun, 9 Mar 2008 15:05:35 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 0EE0D8FC1C for ; Sun, 9 Mar 2008 15:05:34 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.2/8.14.2/NETPLEX) with ESMTP id m29F5U2i002430; Sun, 9 Mar 2008 11:05:30 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.0 (mail.netplex.net [204.213.176.10]); Sun, 09 Mar 2008 11:05:30 -0400 (EDT) Date: Sun, 9 Mar 2008 11:05:30 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: ticso@cicely.de In-Reply-To: <20080309140815.GN34311@cicely12.cicely.de> Message-ID: References: <87D91DEDB1111C44BBFB9E3E90FF1E6E9553E0@host.lodgenet.com> <20080309140815.GN34311@cicely12.cicely.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: FreeBSD Hackers , "Marko, Shaun" Subject: Re: libpthread/fork issue X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Mar 2008 15:05:35 -0000 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