Start a process with its standard input/output connected to an iostream. More...
#include <iopstream.h>
Public Member Functions | |
iopstream (const std::string &command, unsigned int min_debug_level=1) throw (std::runtime_error) | |
Create an input/output stream from/to a process running command . | |
int | close () throw (std::runtime_error) |
Close stream. | |
~iopstream () throw (std::runtime_error) | |
Destructor. | |
Private Member Functions | |
void | start () throw (std::runtime_error) |
Start up a new process. |
Start a process with its standard input/output connected to an iostream.
Definition at line 16 of file iopstream.h.
Dv::Util::iopstream::iopstream | ( | const std::string & | command, | |
unsigned int | min_debug_level = 1 | |||
) | throw (std::runtime_error) |
Create an input/output stream from/to a process running command
.
The process is created using execl
with argument
/bin/sh -c command
Data written to the stream will appear on the standard input of the process. The standard output of the process can be read from the stream.
command | which will be run using /bin/sh -c command | |
min_debug_level | for when the object is connected to a debug master |
std::runtime_error | if anything goes wrong. |
Dv::Util::iopstream::~iopstream | ( | ) | throw (std::runtime_error) |
Destructor.
std::runtime_error | if anything goes wrong. |
int Dv::Util::iopstream::close | ( | ) | throw (std::runtime_error) |
Close stream.
Wait for command to finish, then return its exit status. After a close, the stream is unusable.
std::runtime_error | if command did not exit normally or any other problem. |
void Dv::Util::iopstream::start | ( | ) | throw (std::runtime_error) [private] |
Start up a new process.
std::runtime_error | if fork() failed. | |
std::runtime_error | if execl() failed. | |
std::logic_error | if the process is already running |
/bin/sh -c exec command
Dv::Util::Process proc("ping www.bla.com"); proc.start();
Dv::Util::Process p; if (! p.start()) return f(...); // in the child p.wait(); // in the parent
Reimplemented from Dv::Util::Process.
dvutil-1.0.10 | [ 5 December, 2009] |