From owner-freebsd-threads@FreeBSD.ORG Tue Jun 22 18:26:54 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6A59D16A4CE; Tue, 22 Jun 2004 18:26:54 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 20C2F43D49; Tue, 22 Jun 2004 18:26:54 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id i5MIQXdL017275; Tue, 22 Jun 2004 13:26:33 -0500 (CDT) (envelope-from dan) Date: Tue, 22 Jun 2004 13:26:33 -0500 From: Dan Nelson To: Chris Stenton Message-ID: <20040622182632.GJ86471@dan.emsphone.com> References: <011f01c4578b$923d7b70$4b7ba8c0@gnome.co.uk> <20040622145632.GF86471@dan.emsphone.com> <20040622154056.GA8733@diogenis.ceid.upatras.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040622154056.GA8733@diogenis.ceid.upatras.gr> X-OS: FreeBSD 5.2-CURRENT User-Agent: Mutt/1.5.6i cc: threads@freebsd.org cc: hackers@freebsd.org Subject: Re: pthread - fork - execv problem X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jun 2004 18:26:54 -0000 In the last episode (Jun 22), Nikos Ntarmos said: > On Tue, Jun 22, 2004 at 09:56:33AM -0500, Dan Nelson wrote: > > It may be an application bug. After a fork both processes are > > independant. The child should not be able to affect the parent > > like this, unless the parent does something like holding a mutex > > used by all the threads and calling wait(). > > ... or the child holding a mutex before the fork(2) syscall. FWIW the > Linux info for libc and the NetBSD and Solaris man pages mention > pthread_atfork(3), used to install handlers to take care of such > cases. FreeBSD seems to not know of any such function, so chances are > that fork()'ing from inside a posix thread is not supported (?). It's definitely a possibility. libpthread in -current does support pthread_atfork, and I have a patch (below) that adds the same functionality to libc_r and libthr that I need to send-pr. Pointy hat to the original committer for breaking ABI compatibility. http://dan.allantgroup.com/FreeBSD/ -- Dan Nelson dnelson@allantgroup.com