7 #include <arc/Thread.h>     8 #include <arc/DateTime.h>    26       virtual void Append(
char const* data, 
unsigned int size) = 0;
    27       virtual void Remove(
unsigned int size) = 0;
    28       virtual char const* Get() 
const = 0;
    29       virtual unsigned int Size() 
const = 0;
    41       void Assign(std::string& str, 
int content_max_size = 0);
    42       virtual void Append(
char const* data, 
unsigned int size);
    43       virtual void Remove(
unsigned int size);
    44       virtual char const* Get() 
const;
    45       virtual unsigned int Size() 
const;
    47       std::string* content_;
    48       int content_max_size_;
    52     std::string working_directory;
    71     std::list<std::string> argv_;
    72     std::list<std::string> envp_;
    73     std::list<std::string> envx_;
    74     void (*initializer_func_)(
void*);
    75     void *initializer_arg_;
    76     void (*kicker_func_)(
void*);
    79     typedef bool (
Run::*HandleHandler)();
    80     bool stdout_handler();
    81     bool stderr_handler();
    84     typedef bool (
Run::*PidHandler)(int);
    85     void child_handler(
int result);
    98     Run(
const std::string& cmdline);
   100     Run(
const std::list<std::string>& argv);
   104     operator bool(
void) {
   105       return argv_.size() != 0;
   109       return argv_.size() == 0;
   116     bool Wait(
int timeout);
   146     int ReadStdout(
int timeout, 
char *buf, 
int size);
   155     int ReadStderr(
int timeout, 
char *buf, 
int size);
   164     int WriteStdin(
int timeout, 
const char *buf, 
int size);
   168     void AssignStdout(std::string& str, 
int max_size = 102400);
   173     void AssignStderr(std::string& str, 
int max_size = 102400);
   195     void AssignKicker(
void (*kicker_func)(
void*), 
void *kicker_arg);
   198       working_directory = wd;
   214       envp_.push_back(var);
   218       envx_.push_back(key);
   223     void Kill(
int timeout);
   236 #endif // __ARC_RUN_H__ Arc namespace contains all core ARC classes. 
Definition: ArcConfig.h:11
 
bool Start(void)
Starts running executable. This method may be called only once. 
 
void AssignGroupId(int gid)
Assign gid for the process to run under. 
Definition: Run.h:205
 
void KeepStdout(bool keep=true)
Keep stdout same as parent's if keep = true. No pipe will be created. 
 
void CloseStdout(void)
Closes pipe associated with stdout handle. 
 
void Abandon(void)
Detach this object from running process. 
 
void AssignWorkingDirectory(std::string &wd)
Assign working directory of the process to run. 
Definition: Run.h:197
 
A class for storing and manipulating times. 
Definition: DateTime.h:125
 
int ReadStdout(int timeout, char *buf, int size)
Read from stdout pipe of running executable. 
 
Time ExitTime(void)
Return time when executable finished executing. 
Definition: Run.h:135
 
~Run(void)
Destructor kills running executable and releases associated resources. 
 
void AssignUserId(int uid)
Assign uid for the process to run under. 
Definition: Run.h:201
 
void AssignStderr(std::string &str, int max_size=102400)
Associate stderr pipe of executable with string. 
 
void KeepStderr(bool keep=true)
Keep stderr same as parent's if keep = true. No pipe will be created. 
 
int Result(void)
Returns exit code of execution. 
Definition: Run.h:125
 
void AddEnvironment(const std::string &var)
Add environment variable to be passed to process before it is run. 
Definition: Run.h:213
 
void KeepStdin(bool keep=true)
Keep stdin same as parent's if keep = true. No pipe will be created. 
 
void RemoveEnvironment(const std::string &key)
Remove environment variable to be passed to process before it is run. 
Definition: Run.h:217
 
void AddEnvironment(const std::string &key, const std::string &value)
Add environment variable to be passed to process before it is run. 
Definition: Run.h:209
 
void AssignStdin(std::string &str)
Associate stdin pipe of executable with string. 
 
void AssignStdout(std::string &str, int max_size=102400)
Associate stdout pipe of executable with string. 
 
void AssignInitializer(void(*initializer_func)(void *), void *initializer_arg)
Assign a function to be called just after process is forked but before execution starts. 
 
void CloseStderr(void)
Closes pipe associated with stderr handle. 
 
void AssignKicker(void(*kicker_func)(void *), void *kicker_arg)
Assign a function to be called just after execution ends. It is executed asynchronously. 
 
int ReadStderr(int timeout, char *buf, int size)
Read from stderr pipe of running executable. 
 
void Kill(int timeout)
Kill running executable. 
 
bool operator!(void)
Returns true if object is invalid. 
Definition: Run.h:108
 
Time RunTime(void)
Returns time when executable was started. 
Definition: Run.h:131
 
static void AfterFork(void)
Call this method after fork() in child process. 
 
void CloseStdin(void)
Closes pipe associated with stdin handle. 
 
bool Wait(void)
Wait till execution finished. 
 
bool Running(void)
Return true if execution is going on. 
 
int WriteStdin(int timeout, const char *buf, int size)
Write to stdin pipe of running executable. 
 
This class runs an external executable. 
Definition: Run.h:19