Boost logo

Boost :

Subject: Re: [boost] Boost.Process 0.5 released
From: Roland Bock (rbock_at_[hidden])
Date: 2012-08-19 14:36:38


On 2012-08-19 19:36, Klaim - Joël Lamotte wrote:
> On Sun, Aug 19, 2012 at 6:54 PM, Boris Schaeling <boris_at_[hidden]> wrote:
>
>> I'd also prefer a guaranteed cleanup. But it's not clear how to do this
>> with a RAII type on POSIX (unless you have an idea? :).
>>
> I don't know much about POSIX so I cannot say anything about that at the
> moment.
> If the example you provide in the tutorial is representative of the work
> necessary to request cleanup on posix, then I don't see how putting it as a
> constructor policy wouldn't work?
>
> Something like (assuming the design I suggested and assuming the cleanup
> would be optional- would it be?):
>
> child_process cp( cmd_line("test --foo /bar"), auto_cleanup() );
>
> The work would then be done in the constructor with posix implementation,
> in destructor in windows.
Calling the signal function in the constructor might be a bit strange
since it sets the signal handler for SIGCHLD in general, not just for
this specific child process. That's why I suggested a method that sets
the signal handler (for POSIX) and does nothing for Windows. Some kind
of boost::process::init(ignoreChildSignals, maybe more parameters). This
could be called once during startup of your program.

Then, the destructor could call discard() on Windows, nothing on POSIX.

Or are there additional things to be done for cleanup that I missed?

Regards,

Roland


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