Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class process

boost::process::process

Synopsis

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


class process {
public:
  // construct/copy/destruct
  process(pid_type);
  process(handle);

  // public member functions
  pid_type get_id() const;
  void terminate(bool = false) const;
  int wait() const;
};

Description

Process class to represent any running process.

process public construct/copy/destruct

  1. process(pid_type id);

    Constructs a new process object.

    Creates a new process object that represents a running process within the system.

    On Windows the process is opened and a handle saved. This is required to avoid the operating system removing process resources when the process exits. The handle is closed when the process instance (and all of its copies) is destroyed.

  2. process(handle h);

    Constructs a new process object.

    Creates a new process object that represents a running process within the system.

    This operation is only available on Windows systems. The handle is closed when the process instance (and all of its copies) is destroyed.

process public member functions

  1. pid_type get_id() const;

    Returns the process identifier.

  2. void terminate(bool force = false) const;

    Terminates the process execution.

    Forces the termination of the process execution. Some platforms allow processes to ignore some external termination notifications or to capture them for a proper exit cleanup. You can set the force flag to true to force their termination regardless of any exit handler.

    After this call, accessing this object can be dangerous because the process identifier may have been reused by a different process. It might still be valid, though, if the process has refused to die.

    Throws:

    boost::system::system_error
  3. int wait() const;

    Blocks and waits for the process to terminate.

    Returns an exit code. The process object ceases to be valid after this call.

    Blocking remarks: This call blocks if the process has not finalized execution and waits until it terminates.

    Throws:

    boost::system::system_error

PrevUpHomeNext