Boost logo

Boost :

Subject: Re: [boost] [gsoc] Boost.Process done
From: Boris Schaeling (boris_at_[hidden])
Date: 2010-08-31 17:47:41


On Tue, 31 Aug 2010 15:47:38 +0200, Ilya Sokolov <ilyasokol_at_[hidden]>
wrote:

> [...]I don't think it is good to create files in the constructors of
> classes derived from stream_behavior. Consider the following program
> (untested):
>
> bp::context ctx;
> ctx.stdout_behaviour = bp::behavior::pipe::create(
> bp::behavior::pipe::output_stream);
>
> // 1
> bp::child foo =
> bp::create_child("foo", std::vector<std::string>(), ctx);
>
> // 2
> bp::child bar =
> bp::create_child("bar", std::vector<std::string>(), ctx);
>
> AFAIU, the line 2 will throw exception "dup2() failed" on POSIX, and
> spawn child process with closed(!) stdout on Windows.

Yes, a context can not be reused. In the moment I have no idea though how
to change context without making the interface more complicated. In some
Boost.Process drafts stdout_behavior (and the other member variables) were
enumerations:

ctx.stdout_behavior = pipe;

That was really simple but is neither extensible nor can't data be
attached to a stream behavior (eg. a file descriptor to redirect to).

I tried to make the new stream behavior classes a bit easier to use by
adding the create() method as otherwise everyone would need to use
boost::shared_ptr directly (and probably wonder what boost::shared_ptr has
to do with setting stream behaviors). But I'm open for proposals how to
improve context.

Boris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk