|
Boost : |
Subject: Re: [boost] [gsoc] Boost.Process done
From: Boris Schaeling (boris_at_[hidden])
Date: 2010-09-11 18:15:16
On Sat, 11 Sep 2010 23:24:32 +0200, Jeremy Maitin-Shepard
<jeremy_at_[hidden]> wrote:
> On 09/11/2010 01:51 PM, Jeremy Maitin-Shepard wrote:
>> On 09/11/2010 01:32 PM, Boris Schaeling wrote:
>> [snip]
>
>>> Please have a look at
>>> <http://svn.boost.org/svn/boost/sandbox/SOC/2010/process/libs/process/example/file_descriptors_setup.cpp>.
>>>
> [...]By the way, the example is quite possibly not even correct, because
> file descriptors 3 and 4 might already be in use, and therefore
> depending on the order of operations (and the relative order of
> context::setup and boost process's internal file descriptor setup) the
> code may do the
You are right. If I remember correctly the example isn't tested yet (it
was converted from an example from a previous Boost.Process version).
> wrong thing. That is why all of the file descriptor setup has to be
> coordinated, and therefore why boost process needs to provide an
> interface for doing it.
The interface is context::setup(). The method is called after fork() and
before execve() in the child process only (on POSIX). When
context::setup() is called (only) the standard streams have been
configured and you can do whatever you like with file descriptors
inherited from the parent process. This has also been tested in
<http://svn.boost.org/svn/boost/sandbox/SOC/2010/process/libs/process/test/child.cpp>
(search for "BOOST_AUTO_TEST_CASE(test_posix)"). If you think this test
case misses something I'd be happy to add another one.
Boris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk