Spawn a child process.
More...
#include <spawn.h>
|
| Spawn (const char *const argv[], bool fUseStdErr=false, bool fWithPath=false, const char *const envp[]=NULL) |
| Spawns a child process. More...
|
|
virtual | ~Spawn () |
|
std::istream & | inStream () |
| Access the child process stdout as in stream to read from. More...
|
|
std::ostream & | outStream () |
| Access the child process stdin as out stream to write to the process. More...
|
|
void | sendEof () |
|
int | wait () |
| Wait until child process has terminated. More...
|
|
Spawn a child process.
Usage: spawn s(argv); s.outStream() << ... s.inStream() >> ... s.sendEof(); s.wait();
Definition at line 66 of file spawn.h.
Spawn::Spawn |
( |
const char *const |
argv[], |
|
|
bool |
fUseStdErr = false , |
|
|
bool |
fWithPath = false , |
|
|
const char *const |
envp[] = NULL |
|
) |
| |
Spawns a child process.
- Parameters
-
argv | an array of pointers to null-terminated strings that represent the argument list available to the new program. The first argument, by convention, must point to the filename associated with the file being executed. The array of pointers must be terminated by a NULL pointer. |
fUseStdErr | if true stderr is redirected instead of stdout. |
fWithPath | if true and argv[0] does not contain a slash (/) executable is sought in the PATH environment variable, otherwise PATH is ignored, and the file at the specified pathname is executed. |
envp | is an array of strings, conventionally of the form key=value, which are passed as environment to the new program. must be terminated by a NULL pointer. |
- Exceptions
-
runtime_error | if child process could not be started of if no pipe could be created. |
Definition at line 87 of file spawn.cpp.
Spawn::Spawn |
( |
const Spawn & |
orig | ) |
|
|
private |
Prevent copy-construction.
std::istream& Spawn::inStream |
( |
| ) |
|
|
inline |
Access the child process stdout as in stream to read from.
- Returns
- a istream to read the output of the child process.
Definition at line 77 of file spawn.h.
std::ostream& Spawn::outStream |
( |
| ) |
|
|
inline |
Access the child process stdin as out stream to write to the process.
- Returns
- a ostream to write to the stdin of the child process.
Definition at line 84 of file spawn.h.
Wait until child process has terminated.
The returned status can be inspected with the following macros:
- WIFEXITED(status)
- WEXITSTATUS(status)
- WIFSIGNALED(status)
- WTERMSIG(status)
- WCOREDUMP(status)
- Returns
- the status of the terminated child process or EXIT_FAILURE if an error occurred.
- See also
- wait(2) - Linux manual page - man7.org
Definition at line 172 of file spawn.cpp.
__gnu_cxx::stdio_filebuf<char>* Spawn::m_pReadBuf |
|
private |
__gnu_cxx::stdio_filebuf<char>* Spawn::m_pWriteBuf |
|
private |
std::ostream Spawn::stdin |
|
private |
std::istream Spawn::stdout |
|
private |
The documentation for this class was generated from the following files: