#include <Run.h>
Public Member Functions | |
| Run (const std::string &cmdline) | |
| Run (const std::list< std::string > &argv) | |
| ~Run (void) | |
| operator bool (void) | |
| bool | operator! (void) |
| bool | Start (void) |
| bool | Wait (int timeout) |
| bool | Wait (void) |
| int | Result (void) |
| bool | Running (void) |
| Time | RunTime (void) |
| Time | ExitTime (void) |
| int | ReadStdout (int timeout, char *buf, int size) |
| int | ReadStderr (int timeout, char *buf, int size) |
| int | WriteStdin (int timeout, const char *buf, int size) |
| void | AssignStdout (std::string &str) |
| void | AssignStderr (std::string &str) |
| void | AssignStdin (std::string &str) |
| void | KeepStdout (bool keep=true) |
| void | KeepStderr (bool keep=true) |
| void | KeepStdin (bool keep=true) |
| void | CloseStdout (void) |
| void | CloseStderr (void) |
| void | CloseStdin (void) |
| void | AssignWorkingDirectory (std::string &wd) |
| void | Kill (int timeout) |
| void | Abandon (void) |
Static Public Member Functions | |
| static void | AfterFork (void) |
This class runs external executable. It is possible to read/write it's standard handles or to redirect then to std::string elements.
| Arc::Run::Run | ( | const std::string & | cmdline | ) |
Constructor preapres object to run cmdline
| Arc::Run::Run | ( | const std::list< std::string > & | argv | ) |
Constructor preapres object to run executable and arguments specified in argv
| Arc::Run::~Run | ( | void | ) |
Destructor kills running executable and releases associated resources
| void Arc::Run::Abandon | ( | void | ) |
Detach this object from running process. After calling this method instance is not associated with external process anymore. As result destructor will not kill process.
| static void Arc::Run::AfterFork | ( | void | ) | [static] |
Call this method after fork() in child cporocess. It will reinitialize internal structures for new environment. Do not call it in any other case than defined.
| void Arc::Run::AssignStderr | ( | std::string & | str | ) |
Associate stderr handle of executable with string. This method must be called before Start(). str object must be valid as long as this object exists.
| void Arc::Run::AssignStdin | ( | std::string & | str | ) |
Associate stdin handle of executable with string. This method must be called before Start(). str object must be valid as long as this object exists.
| void Arc::Run::AssignStdout | ( | std::string & | str | ) |
Associate stdout handle of executable with string. This method must be called before Start(). str object must be valid as long as this object exists.
| void Arc::Run::AssignWorkingDirectory | ( | std::string & | wd | ) | [inline] |
Assign working direcotry of the running process
| void Arc::Run::CloseStderr | ( | void | ) |
Closes pipe associated with stderr handle
| void Arc::Run::CloseStdin | ( | void | ) |
Closes pipe associated with stdin handle
| void Arc::Run::CloseStdout | ( | void | ) |
Closes pipe associated with stdout handle
| Time Arc::Run::ExitTime | ( | void | ) | [inline] |
Return when executable finished executing.
| void Arc::Run::KeepStderr | ( | bool | keep = true |
) |
Keep stderr same as parent's if keep = true
| void Arc::Run::KeepStdin | ( | bool | keep = true |
) |
Keep stdin same as parent's if keep = true
| void Arc::Run::KeepStdout | ( | bool | keep = true |
) |
Keep stdout same as parent's if keep = true
| void Arc::Run::Kill | ( | int | timeout | ) |
Kill running executable. First soft kill signal (SIGTERM) is sent to executable. If after timeout seconds executable is still running it's killed completely. Curently this method does not work for Windows OS
| Arc::Run::operator bool | ( | void | ) | [inline] |
Returns true if object is valid
| bool Arc::Run::operator! | ( | void | ) | [inline] |
Returns true if object is invalid
| int Arc::Run::ReadStderr | ( | int | timeout, | |
| char * | buf, | |||
| int | size | |||
| ) |
Read from stderr handle of running executable. Parameter timeout specifies upper limit for which method will block in milliseconds. Negative means infinite. This method may be used while stderr is directed to string. But result is unpredictable. Returns number of read bytes.
| int Arc::Run::ReadStdout | ( | int | timeout, | |
| char * | buf, | |||
| int | size | |||
| ) |
Read from stdout handle of running executable. Parameter timeout specifies upper limit for which method will block in milliseconds. Negative means infinite. This method may be used while stdout is directed to string. But result is unpredictable. Returns number of read bytes.
| int Arc::Run::Result | ( | void | ) | [inline] |
Returns exit code of execution.
| bool Arc::Run::Running | ( | void | ) |
Return true if execution is going on.
| Time Arc::Run::RunTime | ( | void | ) | [inline] |
Return when executable was started.
| bool Arc::Run::Start | ( | void | ) |
Starts running executable. This method may be called only once.
| bool Arc::Run::Wait | ( | void | ) |
Wait till execution finished
| bool Arc::Run::Wait | ( | int | timeout | ) |
Wait till execution finished or till timeout seconds expires. Returns true if execution is complete.
| int Arc::Run::WriteStdin | ( | int | timeout, | |
| const char * | buf, | |||
| int | size | |||
| ) |
Write to stdin handle of running executable. Parameter timeout specifies upper limit for which method will block in milliseconds. Negative means infinite. This method may be used while stdin is directed to string. But result is unpredictable. Returns number of written bytes.
1.6.3