Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Struct async_handler

boost::process::extend::async_handler

Synopsis

// In header: <boost/process/extend.hpp>


struct async_handler : public boost::process::extend::handler,
                       public boost::process::extend::require_io_context
{
};

Description

Inheriting this class will tell the launching function, that an event handler shall be invoked when the process exits. This automatically does also inherit require_io_context.

You must add the following function to your implementation:

template<typename Executor>
std::function<void(int, const std::error_code&)> on_exit_handler(Executor & exec)
{
    auto handler = this->handler;
    return [handler](int exit_code, const std::error_code & ec)
           {
                handler(static_cast<int>(exit_code), ec);
           };

}

The callback will be obtained by calling this function on setup and it will be invoked when the process exits.

[Warning] Warning

Cannot be used with boost::process::spawn


PrevUpHomeNext