29 #ifndef PT_SYSTEM_PROCESS_H
30 #define PT_SYSTEM_PROCESS_H
32 #include <Pt/System/Api.h>
33 #include <Pt/System/Path.h>
34 #include <Pt/System/IODevice.h>
35 #include <Pt/System/SystemError.h>
36 #include <Pt/NonCopyable.h>
90 { _args.push_back(argument);
return *
this; }
95 {
return _args.size(); }
99 const std::string&
arg(std::size_t idx)
const
100 {
return _args.at(idx); }
119 { _stdinMode = mode; }
134 { _stdoutMode = mode; }
149 { _stderrMode = mode; }
168 std::vector<std::string> _args;
220 bool tryWait(
int& status);
232 class ProcessImpl *_impl;
248 std::string cmdline = _command.
toLocal();
250 for( std::size_t i = 0; i < _args.size(); ++i )
251 cmdline +=
' ' + _args[i];
260 #endif // PT_SYSTEM_PROCESS_H
Core module.
Definition: pt-gfx-images.dox:14
bool isStdInputRedirected() const
Returns true if stdin will be redirected.
Definition: Process.h:128
IOMode
Flags for process I/O.
Definition: Process.h:71
bool isStdOutputClosed() const
Returns true if stdout will be closed.
Definition: Process.h:138
bool isDetached() const
Returns true if process should detach.
Definition: Process.h:108
int wait()
Waits until the Process ends.
Executes shell commands.
Definition: Process.h:177
ProcessFailed()
Default Constructor.
IODevice * stdOutput()
Returns an I/O device to stdout.
Indicates process failure.
Definition: Process.h:51
void setStdInput(IOMode mode)
Sets I/O flags for stdin.
Definition: Process.h:118
void setDetached(bool sw)
Process should detach.
Definition: Process.h:113
bool isStdOutputRedirected() const
Returns true if stdout will be redirected.
Definition: Process.h:143
@ Redirect
Redirect I/O.
Definition: Process.h:74
~ProcessFailed()
Destructor.
Definition: Process.h:59
bool isStdErrorAsOutput() const
Returns true if stderr and atdout wil be combined.
Definition: Process.h:163
Exception class indication a system error.
Definition: SystemError.h:43
const ProcessInfo & procInfo() const
Returns the process parameters.
bool isStdErrorRedirected() const
Returns true if stderr will be redirected.
Definition: Process.h:158
@ Keep
Keep open.
Definition: Process.h:72
bool isStdInputClosed() const
Returns true if stdin will be closed.
Definition: Process.h:123
void setStdOutput(IOMode mode)
Sets I/O flags for stdout.
Definition: Process.h:133
IODevice * stdInput()
Returns an I/O device to stdin.
Process(const ProcessInfo &procInfo)
Constructs with a process parameters.
void kill()
Kills the Process.
State
State of the process.
Definition: Process.h:182
std::string toString() const
Returns full command line.
Definition: Process.h:246
ProcessInfo & addArg(const std::string &argument)
Adds an argument to the list of arguments.
Definition: Process.h:89
IODevice * stdError()
Returns an I/O device to stderr.
Represents a path in the file-system.
Definition: Path.h:48
const std::string & arg(std::size_t idx) const
Returns a command line argument.
Definition: Process.h:99
Endpoint for I/O operations.
Definition: IODevice.h:56
@ Close
Close I/O.
Definition: Process.h:73
@ ToStdOut
Combine stderr with stdout, only valid for stderr.
Definition: Process.h:75
State state() const
Returns the current state.
void start()
Start/Create the Process.
std::size_t argCount() const
Number of command line arguments.
Definition: Process.h:94
Protects derived classes from being copied.
Definition: NonCopyable.h:54
const Path & command() const
Command to execute.
Definition: Process.h:84
bool isStdErrorClosed() const
Returns true if stderr will be closed.
Definition: Process.h:153
Process startup parameters
Definition: Process.h:66
ProcessInfo(const Path &command)
Construct with command to execute.
Definition: Process.h:236
void setStdError(IOMode mode)
Sets I/O flags for stderr.
Definition: Process.h:148
std::string toLocal() const
Returns the path name in local encoding.