From owner-freebsd-hackers@FreeBSD.ORG Fri Sep 9 08:32:15 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E952916A41F for ; Fri, 9 Sep 2005 08:32:15 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from comsys.ntu-kpi.kiev.ua (comsys.ntu-kpi.kiev.ua [195.245.194.142]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8BDEE43D53 for ; Fri, 9 Sep 2005 08:31:21 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from pm514-9.comsys.ntu-kpi.kiev.ua (pm514-9.comsys.ntu-kpi.kiev.ua [10.18.54.109]) (authenticated bits=0) by comsys.ntu-kpi.kiev.ua (8.12.10/8.12.10) with ESMTP id j898cw82076519 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 9 Sep 2005 11:38:58 +0300 (EEST) Received: by pm514-9.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1000) id D6BBB83; Fri, 9 Sep 2005 11:28:33 +0300 (EEST) Date: Fri, 9 Sep 2005 11:28:33 +0300 From: Andrey Simonenko To: erkan kolemen Message-ID: <20050909082833.GA278@pm514-9.comsys.ntu-kpi.kiev.ua> References: <20050908194020.21635.qmail@web33415.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050908194020.21635.qmail@web33415.mail.mud.yahoo.com> User-Agent: Mutt/1.4.2.1i X-Spam-Status: No, score=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.0.1 X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on comsys.ntu-kpi.kiev.ua X-Virus-Scanned: ClamAV 0.82/1049/Wed Aug 31 10:19:01 2005 on comsys.ntu-kpi.kiev.ua X-Virus-Status: Clean Cc: freebsd-hackers@freebsd.org Subject: Re: fok() execve() -> No child processes X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Sep 2005 08:32:16 -0000 On Thu, Sep 08, 2005 at 12:40:20PM -0700, erkan kolemen wrote: > Following code fails. I debugged it and saw that: it > produces "No child processes" error while wait(). > > is it possible, parent still is not start to wait but > child finished. After that CPU schedules parents. It > try to start wait but child has finished. > > is it possible... What can i do for that? If you want to use vfork(), then you should know that a child will borrow parent's memory and a parent is suspended while a child is using its resources (at least in BSD). A child is allowed to call only execve() or _exit() and it is not allowed to return from the function in which vfork() was called. A child can modify some data in the parent's memory (really shared memory by both processes), but this memory should be volatile (try to modify non-volatile variable in a child and check result in a parent and compile this test program with optimization). Read description and "application usage" of vfork() in SUSv3, it gives very hard limits on vfork() usage (if you are interesting in creating portable software). Also find discussions about vfork() in this mailing list and read another limitations on its usage in found letters.