#include <child_reader.h>
Public Member Functions | |
| child_reader (std::string const &cmd, std::vector< std::string > const &args) | |
| fork a process. | |
| ~child_reader () | |
| wait for the termination of the child process if this have not already occur. | |
| bool | getline (std::string &result) |
| fill result from on line of stdout of the child process. | |
| bool | get_data (std::ostream &out, std::ostream &err) |
| fill out / err with the stdout / stderr of the child process. | |
| int | terminate_process () |
| rather to rely on dtor to wait for the termination of the child you can use terminate_process() to get the return code of the child process | |
| int | error () const |
| return the status of the first error encoutered != 0 : something feel wrong, use error_str() to get an error message | |
| std::string | error_str () const |
| return an error message if appropriate, if the process has been successfully exec'ed and is not terminate the error message is always empty. | |
two interfaces are provided. read line by line: getline() or read all data in one : get_data(). In all case get_data() must be called once to flush the stderr child output
|
||||||||||||
|
fork a process. use error() to get error code. Do not try to use other public member interface if error() return non-zero |
|
|
wait for the termination of the child process if this have not already occur. In this case return code of the child process is not available. |
|
|
return the status of the first error encoutered != 0 : something feel wrong, use error_str() to get an error message
|
|
|
return an error message if appropriate, if the process has been successfully exec'ed and is not terminate the error message is always empty. Error message is also empty if the child process terminate successfully. Else three type of error message exist:
|
|
||||||||||||
|
fill out / err with the stdout / stderr of the child process. You can call this after calling one or more time getline(...). This call is blocking until the child die and so on all subsequent call will fail |
|
|
fill result from on line of stdout of the child process. must be used as: child_reader reader(...); while (reader.getline(line)) .... |
|
|
rather to rely on dtor to wait for the termination of the child you can use terminate_process() to get the return code of the child process
|
1.4.6