Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class pistream

boost::process::pistream

Synopsis

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


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

  // public member functions
  const boost::process::handle & handle() const;
  boost::process::handle & handle() ;
  void close() ;
};

Description

Child process' output stream.

The pistream class represents an output communication channel with the child process. The child process writes data to this stream and the parent process can read it through the pistream object. In other words, from the child's point of view, the communication channel is an output one, but from the parent's point of view it is an input one; hence the confusing pistream name.

pistream objects cannot be copied because they buffer data that flows through the communication channel.

A pistream object behaves as a std::istream stream in all senses. The class is only provided because it must provide a method to let the caller explicitly close the communication channel.

Blocking remarks: Functions that read data from this stream can block if the associated handle blocks during the read. As this class is used to communicate with child processes through anonymous pipes, the most typical blocking condition happens when the child has no more data to send to the pipe's system buffer. When this happens, the buffer eventually empties and the system blocks until the writer generates some data.

pistream public construct/copy/destruct

  1. pistream(boost::process::handle h);

    Creates a new process' output stream.

pistream public member functions

  1. const boost::process::handle & handle() const;

    Returns the handle managed by this stream.

  2. boost::process::handle & handle() ;

    Returns the handle managed by this stream.

  3. void close() ;

    Closes the handle managed by this stream.

    Explicitly closes the handle managed by this stream. This function can be used by the user to tell the child process it's not willing to receive more data.


PrevUpHomeNext