Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Struct template posix_executor

boost::process::extend::posix_executor — The posix executor type.

Synopsis

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

template<typename Sequence> 
struct posix_executor {

  // public member functions
   () ;
   (, );
   (, );

  // public data members
   seq;  // A reference to the actual initializer-sequence. 
   exe;  // A pointer to the name of the executable. 
   cmd_line;  // A pointer to the argument-vector. 
   env;  // A pointer to the environment variables, as default it is set to environ
   pid;  // The pid of the process - it will be -1 before invoking fork, and after forking either 0 for the new process or a positive value if in the current process. *<zwj></zwj>/. 
   exit_status;  // This shared-pointer holds the exit code. It's done this way, so it can be shared between an asio::io_context and child. 
};

Description

This type represents the posix executor and can be used for overloading in a custom handler.

[Note] Note

It is an alias for the implementation on posix, and a forward-declaration on windows.

As information for extension development, here is the structure of the process launching (in pseudo-code and uml)

on_setup(*error())
{
    on_error(*error());
    child();
}


on_setup(*set_error(get_last_error());
    on_fork_error(*error());
    on_error(*error());
    child()
}
on_exec_setup(*(get_last_error();
    on_exec_error(*//here the error is sent to the father process internally

    ();
    child(); //for C++ compliance
}

child //here, we read the error from the child process

error())
    on_error(*error());
on_success(*error())
{
    on_error(*error());
    child();
}

The sequence if when no error occurs.

The sequence if the execution fails.

The sequence if the fork fails.

[Note] Note

Error handling if execve fails is done through a pipe, unless ignore_error is used.

Template Parameters

  1. typename Sequence

    The used initializer-sequence, it is fulfills the boost.fusion sequence concept.

posix_executor public member functions

  1.  () ;
    This function returns a const reference to the error state of the executor.
  2.  ( ec,  msg);

    This function can be used to report an error to the executor. This will be handled according to the configuration of the executor, i.e. it might throw an exception.

    [Note] Note

    This is the required way to handle errors in initializers.

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

  3.  ( ec,  msg);

PrevUpHomeNext