From owner-freebsd-questions@FreeBSD.ORG Wed Apr 30 04:41:53 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 539221E6 for ; Wed, 30 Apr 2014 04:41:53 +0000 (UTC) Received: from ms-10.1blu.de (ms-10.1blu.de [178.254.4.101]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 105BF1982 for ; Wed, 30 Apr 2014 04:41:52 +0000 (UTC) Received: from [188.174.55.229] (helo=localhost.my.domain) by ms-10.1blu.de with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1WfML8-0007HI-7v for freebsd-questions@freebsd.org; Wed, 30 Apr 2014 06:41:50 +0200 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.my.domain (8.14.7/8.14.3) with ESMTP id s3U4fqCs001722 for ; Wed, 30 Apr 2014 06:41:52 +0200 (CEST) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.14.7/8.14.3/Submit) id s3U4fqtu001721 for freebsd-questions@freebsd.org; Wed, 30 Apr 2014 06:41:52 +0200 (CEST) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Wed, 30 Apr 2014 06:41:51 +0200 From: Matthias Apitz To: freebsd-questions@freebsd.org Subject: Re: system(3) && open file descriptors Message-ID: <20140430044151.GA1668@La-Habana> References: <20140429184307.GA1114@tiny-r255948> <71BBF914-AA3A-4701-8395-0A5C49474948@mac.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <71BBF914-AA3A-4701-8395-0A5C49474948@mac.com> X-Operating-System: FreeBSD 9.0-CURRENT r214444 (i386) User-Agent: Mutt/1.5.21 (2010-09-15) X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 188.174.55.229 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: Matthias Apitz List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Apr 2014 04:41:53 -0000 El día Tuesday, April 29, 2014 a las 02:41:22PM -0700, Charles Swiger escribió: > Hi-- > > On Apr 29, 2014, at 11:43 AM, Matthias Apitz wrote: > > It seems that the proc started by the C library call system(3), as > > /bin/sh -c string > > owns the same set of open file descriptors as its calling proc. Is this > > somewhere documented as a feature? 'man system" does not say anything > > about, while 'man fork' does. > > At least my version of system(3) says that it invokes fork(2) and checks > the exit status of the shell via waitpid(2). That plus listing fork(2) > in SEE ALSO section seems to be enough of a pointer to the detailed > behavior.... Hi, Ofc it must use fork(2), but it *could* as well close all fd before execv(2). IMHO it should do this for all fd > 2, at least the man page should mention the fact that it does not. matthia -- Matthias Apitz | /"\ ASCII Ribbon Campaign: E-mail: guru@unixarea.de | \ / - No HTML/RTF in E-mail WWW: http://www.unixarea.de/ | X - No proprietary attachments phone: +49-170-4527211 | / \ - Respect for open standards | en.wikipedia.org/wiki/ASCII_Ribbon_Campaign