#include <process.h>

Public Member Functions | |
| Process () | |
| virtual | ~Process () |
| std::string | Start (char *file, char **argv) |
| Starts the subprocess. | |
| std::string | Fork () |
| Fork the current process. | |
| int | GetPID () |
| Get the pidof of the subprocess. | |
| int | GetExitCode () |
| Read the exit status of the subprocess. | |
| std::string | GetOutput (char *buf, unsigned int &len, int &fd) |
| Read from standard outputs of the subprocess. | |
| std::string | SendStdin (char *buf, int len) |
| Send data to the standard input of the subprocess. | |
| void | SendStdinClose () |
| Closes the standard input of the subprocess. | |
Protected Member Functions | |
| virtual std::string | ParentOnFork () |
| Call from the parent process after when the process is forking. | |
| virtual std::string | ChildOnFork () |
| Call from the child process after when the process is forking. | |
| virtual std::string | HandleEvents () |
| Handle events of the process. | |
Protected Attributes | |
| int | exit_code |
| pid_t | pid |
Allows to start a subprocess asynchronously. Provide some methods to read and write to the subprocess standard input / output
Definition at line 12 of file process.h.
| Process::Process | ( | ) |
Definition at line 13 of file process.cpp.
| Process::~Process | ( | ) | [virtual] |
Definition at line 28 of file process.cpp.
| virtual std::string Process::ChildOnFork | ( | ) | [inline, protected, virtual] |
| std::string Process::Fork | ( | ) |
Fork the current process.
Definition at line 80 of file process.cpp.
| int Process::GetExitCode | ( | ) |
Read the exit status of the subprocess.
Definition at line 172 of file process.cpp.
| std::string Process::GetOutput | ( | char * | buf, | |
| unsigned int & | len, | |||
| int & | fd | |||
| ) |
Read from standard outputs of the subprocess.
The standard output (stdout and stderr) are checked for available data. This method is non bloquant.
| buf | pointer to buffer where to store the output. | |
| len | unsigned integer specifying the size of the passed buffer. It contains the number of characters read when the call returns. | |
| fd | is not used on input. It contains the file descriptor that had output data (1 for stdout, 2 for stderr) when the call returns. |
Definition at line 101 of file process.cpp.
| int Process::GetPID | ( | ) |
Get the pidof of the subprocess.
Definition at line 96 of file process.cpp.
| std::string Process::HandleEvents | ( | ) | [protected, virtual] |
Handle events of the process.
Should update the exit_code member. Called from the GetOutput and SendStdin methods.
Definition at line 194 of file process.cpp.
| virtual std::string Process::ParentOnFork | ( | ) | [inline, protected, virtual] |
| std::string Process::SendStdin | ( | char * | buf, | |
| int | len | |||
| ) |
Send data to the standard input of the subprocess.
| buf | Input buffer to send. | |
| len | Size of the buffer to pass. |
Definition at line 177 of file process.cpp.
| void Process::SendStdinClose | ( | ) |
Closes the standard input of the subprocess.
Trigger an end of file on the standard input of the subprocess.
Definition at line 189 of file process.cpp.
| std::string Process::Start | ( | char * | file, | |
| char ** | argv | |||
| ) |
Starts the subprocess.
Arguments to this method are passed unmodified to the execvp syscall.
| file | path to the binary file to execute. | |
| argv | array of null terminated strings passed as arguments to the command. The last element of the array must be a NULL pointer. |
Definition at line 38 of file process.cpp.
int Process::exit_code [protected] |
pid_t Process::pid [protected] |
1.5.8