HDK
|
#include <UT_WritePipe.h>
Public Member Functions | |
UT_WritePipe (const char *cmd=0, bool change_process_group=false) | |
~UT_WritePipe () | |
FILE * | open (const char *cmd) |
FILE * | open (const char *cmd, FILE *kid_stdout, FILE *kid_stderr) |
int | close (bool wait_for_child_to_terminate=false) |
bool | isComplete (bool block=false) |
void | suspend () |
Suspend pipe process. More... | |
void | restart () |
Restart pipe process after suspended. More... | |
false is liable *to return false if you call it right after this Use * | isComplete (true)`to ensure the pipe process is fully *complete before continuing |
false is liable *to return false if you call it right after this Use or call | close ()`with block set to true.*/void terminate() |
bool | isSuspended () const |
Is pipe process suspended? More... | |
FILE * | getFilePtr () |
Return file handle for last open() call. More... | |
int | getErrno () const |
int | getStatus () const |
pid_t | getPid () const |
This method will return the child process id. More... | |
Definition at line 30 of file UT_WritePipe.h.
|
explicit |
Construct pipe
cmd | If given, opens the cmd before returning. Call getFilePtr() for the actual created file handle. |
change_process_group | Puts the child process in a new process group to isolate the parent from any crashes coming from the child. |
UT_WritePipe::~UT_WritePipe | ( | ) |
Destruct pipe
If the pipe is open and destructed, the process will be blocked until the child is terminated.
int UT_WritePipe::close | ( | bool | wait_for_child_to_terminate = false | ) |
Close the pipe
false is liable* to return false if you call it right after this Use or call UT_WritePipe::close | ( | ) |
|
inline |
If close() fails, you can get the errno of the fail call by calling this method. If the child is still running, the error will be set to EWOULDBLOCK
Definition at line 103 of file UT_WritePipe.h.
|
inline |
Return file handle for last open() call.
Definition at line 98 of file UT_WritePipe.h.
|
inline |
This method will return the child process id.
Definition at line 110 of file UT_WritePipe.h.
|
inline |
If close() succeeds, you can get the exit status of the child process by calling the following method.
Definition at line 107 of file UT_WritePipe.h.
bool UT_WritePipe::isComplete | ( | bool | block = false | ) |
Call this to find out whether it's safe to close (i.e. the child process has terminated). This can be called before, or after the pipe has been closed.
false is liable* to return false if you call it right after this Use* UT_WritePipe::isComplete | ( | true | ) |
Terminate pipe process
bool UT_WritePipe::isSuspended | ( | ) | const |
Is pipe process suspended?
|
inline |
Open a command as a write pipe. The file descriptor returned will be the command's stdin.
Definition at line 52 of file UT_WritePipe.h.
FILE* UT_WritePipe::open | ( | const char * | cmd, |
FILE * | kid_stdout, | ||
FILE * | kid_stderr | ||
) |
Open a command as a write pipe. The file descriptor returned will be the command's stdin. If the kid_stdout
file descriptor is given, this will become stdout for the child. If kid_stderr
is specified, it will be come stderr for the child.
void UT_WritePipe::restart | ( | ) |
Restart pipe process after suspended.
void UT_WritePipe::suspend | ( | ) |
Suspend pipe process.