Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Apr 2014 06:41:51 +0200
From:      Matthias Apitz <guru@unixarea.de>
To:        freebsd-questions@freebsd.org
Subject:   Re: system(3) && open file descriptors
Message-ID:  <20140430044151.GA1668@La-Habana>
In-Reply-To: <71BBF914-AA3A-4701-8395-0A5C49474948@mac.com>
References:  <20140429184307.GA1114@tiny-r255948> <71BBF914-AA3A-4701-8395-0A5C49474948@mac.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <guru@unixarea.de> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140430044151.GA1668>