|
struct AProcess : public NoCopy
This is an abstract class that represent a controlled child process. Client code can communicate with such process by supplying standard input and reading standard output. Note that while LocalProcess implements AProcess for host OS, some other derived class might choose to e.g. represent a process on remote system.
virtual void Kill() = 0
Terminates running process.
virtual bool IsRunning() = 0
Returns true if process is running.
virtual void Write(String s) = 0
Sends a text to standard input of process.
virtual bool Read(String& s) = 0
Reads data from standard output. Returns true if there process was running or there are more data to be read.
virtual int GetExitCode() = 0
Returns an exit code of terminated process.
virtual void Detach()
Disconnects AProcess instance from running child process. Process continues to run while AProcess instance can be destructed.
String Get()
This utility inline function calls Read and returns the standard output of process. If anything went wrong, returns String::GetVoid().
class LocalProcess : public AProcess
This class implements a child process of host operating system.
bool Start(const char *cmdline, const char *envptr = NULL)
Starts a new process defined by cmdline, envptr can provide a new environment for the process, if NULL, then the new process inherits caller's environment.
LocalProcess& ConvertCharset(bool b = true)
LocalProcess& NoConvertCharset()
Determines LocalProcess should convert encoding from system to application one. Default setting is true.
LocalProcess()
Default constructor.
LocalProcess(const char *cmdline, const char *envptr = NULL)
Equivalent of default constructor and then invoking Start(cmdline, envptr).
Global functions related to LocalProcess
|
|
int Sys(const char *cmd, String& out, bool convertcharset = true)
Runs process defined by cmd command line, returns its standard output in output.and its exit code as return value. If there was error invoking cmd, returns -1. If convertcharset is true, output is converted from system character encoding to application encoding.
String Sys(const char *cmd, bool convertcharset = true)
Runs process defined by cmd command line. If cmd was executed successfully and returned zero exit code, returns its standard output, otherwise returns String::GetVoid(). If convertcharset is true, output is converted from system character encoding to application encoding.
|