Boost logo

Boost :

Subject: Re: [boost] Process library with child process events
From: Boris Schaeling (boris_at_[hidden])
Date: 2011-06-05 19:10:53


On Wed, 01 Jun 2011 23:45:29 +0200, Klaim - Joël Lamotte
<mjklaim_at_[hidden]> wrote:

> [...]I've read the current (clearly incomplete w.i.p.) doc and parsed
> the
> headers and I like the design so far.
> However, I can't find a way to be notified if a child process did end, by
> getting to the end of the program or by having crashed or by having being
> shut down by external processes, the OS or the user.

I'm a bit late with my response. But I just finished a first (early)
version of what may become a new Windows service for Boost.Asio. The
service is based on WaitForMultipleObjects() which can be used (among
others) to be notified when a child processes terminates. As
WaitForMultipleObjects() can be used for many more things (see the remarks
at http://msdn.microsoft.com/en-us/library/ms687025(v=vs.85).aspx), I try
to create a more general service which is not bound to Boost.Process. (I
agree with Danny that on Unix boost::asio::signal_set from Boost.Asio
1.5.3 should be used.)

If you like to give it a try - here's a Visual C++ 2010 project:
http://www.highscore.de/boost/AsioObjectHandle.zip

The ZIP file is pretty big (3 MB) as I use Google Test and Google Mock and
have included those libraries. But then you only need to have Boost 1.46.1
installed (at least that's what I use). As the VC++ project expects to
find Boost headers and libs in C:\Boost\include and C:\Boost\lib, you may
need to update the project configuration.

If you like to see first how the extension is used:

-----
void YOUR_HANDLER(boost::system::error_code ec) {}

boost::asio::io_service io_service;
boost::asio::windows::object_handle obj_handle(io_service,
YOUR_WINDOWS_HANDLE);
obj_handle.async_wait(YOUR_HANDLER);
io_service.run();
-----

The new I/O object object_handle complements random_access_handle and
stream_handle. While the latter two are used to read and write (they exist
already in Boost.Asio), object_handle is used to wait for a signaled
state. The only asynchronous operation supported is async_wait().

Please note that the service is neither complete (eg. cancel() hasn't been
implemented yet) nor documented nor sufficiently tested. The more people
play around with it, the faster it will be complete though. :)

I'll send an email to the asio mailing list in the coming days to discuss
the implementation.

Boris


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