Boost C++ Libraries

PrevUpHomeNext

Class posix_child

boost::process::posix_child — POSIX implementation of the Child concept.

Synopsis

class posix_child : public boost::process::child {
public:
// construct/copy/destruct
posix_child(handle_type, unspecified, unspecified);

// public member functions
postream & get_input(int) const;
pistream & get_output(int) const;
};

Description

The posix_child class implements the Child concept in a POSIX operating system.

A POSIX child differs from a regular child (represented by a child object) in that it supports more than three communication channels with its parent. These channels are identified by regular file descriptors (integers).

This class is built on top of the generic child so as to allow its trivial adoption. When a program is changed to use the POSIX-specific launcher (posix_launcher), it will most certainly need to migrate its use of the child class to posix_child. Doing so is only a matter of redefining the appropriate object and later using the required extra features: there should be no need to modify the existing code (e.g. method calls) in any other way.

posix_child construct/copy/destruct

  1. posix_child(handle_type h, unspecified infoin, unspecified infoout);

    Creates a new child object that represents the just spawned process h.

    The infoin and infoout maps contain the pipes used to handle the redirections of the child process; at the moment, no other stream_info types are supported. If the launcher was asked to redirect any of the three standard flows, their pipes must be present in these maps.

    This constructor is protected because the library user has no business in creating representations of live processes himself; the library takes care of that in all cases.

posix_child public member functions

  1. postream & get_input(int desc) const;

    Returns a reference to a postream object that represents one of the multiple input communication channels with the child process. The channel is identified by desc as seen from the child's point of view. The parent can use the returned stream to send data to the child.

    Giving this function the STDIN_FILENO constant (defined in cstdlib) is a synonym for the get_stdin() call inherited from child.

  2. pistream & get_output(int desc) const;

    Returns a reference to a pistream object that represents one of the multiple output communication channels with the child process. The channel is identified by desc as seen from the child's point of view. The parent can use the returned stream to retrieve data from the child.

    Giving this function the STDOUT_FILENO or STDERR_FILENO constants (both defined in cstdlib) are synonyms for the get_stdout() and get_stderr() calls inherited from child, respectively.

Copyright 2006 Julio M. Merino Vidal

PrevUpHomeNext