From owner-freebsd-threads@FreeBSD.ORG Fri Jun 13 09:29:44 2003 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 0EEEF37B401 for ; Fri, 13 Jun 2003 09:29:44 -0700 (PDT) Received: from stork.mail.pas.earthlink.net (stork.mail.pas.earthlink.net [207.217.120.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7B87E43F93 for ; Fri, 13 Jun 2003 09:29:43 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from user-38lc0hv.dialup.mindspring.com ([209.86.2.63] helo=mindspring.com) by stork.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 19QrQg-0003tP-00; Fri, 13 Jun 2003 09:29:31 -0700 Message-ID: <3EE9FBA5.BFFC35DC@mindspring.com> Date: Fri, 13 Jun 2003 09:28:21 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Petri Helenius References: <07fc01c331aa$41758cd0$812a40c1@PETEX31> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a46dd0c9117bf44b6f677bb11bf709b50093caf27dac41a8fd350badd9bab72f9c350badd9bab72f9c cc: freebsd-threads@freebsd.org Subject: Re: fork semantics 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: Fri, 13 Jun 2003 16:29:44 -0000 Petri Helenius wrote: > Could somebody point me how fork is wrapped/implemented with libkse ? http://www.opengroup.org/onlinepubs/007904975/nfindex.html > Do all threads get duplicated and which would be the recommended way to > spin something off hanging on a pipe talking to one of the threads already in > existence? "A process shall be created with a single thread. 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. [THR] Fork handlers may be established by means of the pthread_atfork() function in order to maintain application invariants across fork() calls. When the application calls fork() from a signal handler and any of the fork handlers registered by pthread_atfork() calls a function that is not asynch-signal-safe, the behavior is undefined." -- Terry