blocxx
|
Namespaces | |
namespace | Impl |
Classes | |
class | PreExec |
This class is used to specify what spawn() should do between fork and exec. More... | |
class | OutputCallback |
class | InputCallback |
Enumerations | |
enum | EOutputSource { E_STDOUT, E_STDERR } |
Functions | |
Process::Status | system (const Array< String > &command, const char *const envp[]=0, const Timeout &=Timeout::infinite) |
Execute a command. | |
int | safeSystem (const Array< String > &command, const char *const envp[]=0) BLOCXX_DEPRECATED |
This is deprecated. | |
ProcessRef | spawnImpl (char const *exec_path, char const *const argv[], char const *const envp[], PreExec &pre_exec) |
ProcessRef | spawn (char const *exec_path, char const *const argv[], char const *const envp[], PreExec &pre_exec) |
Run the executable exec_path in a child process, with argv for the program arguments and envp for the environment. | |
ProcessRef | spawn (char const *const argv[], char const *const envp[]) |
Variant of spawn that uses StandardPreExec . | |
Process::Status | executeProcessAndGatherOutput (char const *const command[], String &output, char const *const envVars[], const Timeout &timeout=Timeout::infinite, int outputlimit=-1, char const *input=0) |
Execute a command and run feedProcessAndGatherOutput() on the process. | |
Process::Status | executeProcessAndGatherOutput (char const *const command[], String &output, String &erroutput, char const *const envVars[], const Timeout &timeout=Timeout::infinite, int outputLimit=-1, char const *input=0) |
Execute a command and run feedProcessAndGatherOutput() on the process. | |
BLOCXX_COMMON_API void | executeProcessAndGatherOutput (const Array< String > &command, String &output, int &processstatus, int timeoutsecs, int outputlimit, const String &input) |
Process::Status | feedProcessAndGatherOutput (ProcessRef const &proc, String &output, Timeout const &timeout=Timeout::infinite, int outputlimit=-1, String const &input=String()) |
Send input to a process, collect the output, and wait for it to exit. | |
Process::Status | feedProcessAndGatherOutput (ProcessRef const &proc, String &output, String &erroutput, Timeout const &timeout=Timeout::infinite, int outputLimit=-1, String const &input=String()) |
Send input to a process, collect STDOUT and STDERR, and wait for it to exit. | |
void | gatherOutput (String &output, const ProcessRef &proc, int timeoutSecs, int outputLimit) |
void | gatherOutput (String &output, const ProcessRef &proc, const Timeout &timeout=Timeout::infinite, int outputlimit=-1) |
Wait for output from a child process. | |
void | processInputOutput (OutputCallback &output, Array< ProcessRef > &procs, InputCallback &input, const Timeout &timeout=Timeout::infinite) |
Send input and wait for output from child processes. | |
void | processInputOutput (const String &input, String &output, const ProcessRef &process, const Timeout &timeout, int outputLimit) |
template<typename SA1 , typename SA2 > | |
Process::Status | system (const SA1 &command, const SA2 &envVars, const Timeout &timeout=Timeout::infinite) |
template<typename S , typename SA1 , typename SA2 > | |
ProcessRef | spawn (S const &exec_path, SA1 const &argv, SA2 const &envp, PreExec &pre_exec) |
Variant of spawn that allows exec_path to have an arbitrary string-like type, and argv and envp to have arbitrary string-array-like types. | |
template<typename SA1 , typename SA2 > | |
ProcessRef | spawn (SA1 const &argv, SA2 const &envp) |
Variant of spawn that uses StandardPreExec and argv and envp to have arbitrary string-array-like types. | |
template<typename SA1 > | |
ProcessRef | spawn (SA1 const &argv) |
template<typename SA1 , typename S1 , typename S2 > | |
Process::Status | executeProcessAndGatherOutput (SA1 const &command, S1 &output, const Timeout &timeout, int outputlimit, S2 const &input) |
Version of executeProcessAndGatherOutput() that passes the current process's environment to the child process. | |
template<typename SA1 , typename S1 , typename S2 > | |
Process::Status | executeProcessAndGatherOutput (SA1 const &command, S1 &output, S1 &erroutput, const Timeout &timeout, int outputlimit, S2 const &input) |
Version of executeProcessAndGatherOutput() that passes the current process's environment to the child process and separates STDOUT and STDERR. | |
template<typename SA1 , typename S1 > | |
Process::Status | executeProcessAndGatherOutput (SA1 const &command, S1 &output, const Timeout &timeout=Timeout::infinite, int outputlimit=-1) |
Version of executeProcessAndGatherOutput() that passes the current process's environment to the child process. | |
template<typename SA1 , typename S1 > | |
Process::Status | executeProcessAndGatherOutput (SA1 const &command, S1 &output, S1 &erroutput, const Timeout &timeout=Timeout::infinite, int outputlimit=-1) |
Version of executeProcessAndGatherOutput() that passes the current process's environment to the child process and collects STDOUT and STDERR separately. | |
template<typename SA1 , typename S1 , typename SA2 , typename S2 > | |
Process::Status | executeProcessAndGatherOutput (SA1 const &command, S1 &output, SA2 const &envp, const Timeout &timeout, int outputlimit, S2 const &input) |
Variant of executeProcessAndGatherOutput that allows command and envp to have arbitrary string-array-like types and output to have an arbitrary string-like type. | |
template<typename SA1 , typename S1 , typename SA2 , typename S2 > | |
Process::Status | executeProcessAndGatherOutput (SA1 const &command, S1 &output, S1 &erroutput, SA2 const &envp, const Timeout &timeout, int outputlimit, S2 const &input) |
Variant of executeProcessAndGatherOutput that allows command and envp to have arbitrary string-array-like types and output to have an arbitrary string-like type. | |
template<typename SA1 , typename S1 , typename SA2 > | |
Process::Status | executeProcessAndGatherOutput (SA1 const &command, S1 &output, S1 &erroutput, SA2 const &envp, const Timeout &timeout=Timeout::infinite, int outputlimit=-1) |
Version of executeProcessAndGatherOutput() that passes no input to the process. | |
template<typename S , typename SA1 , typename SA2 > | |
ProcessRef | spawnImpl (S const &exec_path, SA1 const &argv, SA2 const &envp, PreExec &pre_exec) |
Variant of spawnImpl that allows exec_path to have an arbitrary string-like type, and argv and envp to have arbitrary string-array-like types. | |
ProcessRef | spawnImpl (char const *const argv[], char const *const envp[]) |
Variant of spawnImpl that uses StandardPreExec . | |
template<typename SA1 , typename SA2 > | |
ProcessRef | spawnImpl (SA1 const &argv, SA2 const &envp) |
Variant of spawnImpl that uses StandardPreExec and argv and envp to have arbitrary string-array-like types. | |
template<typename SA1 > | |
ProcessRef | spawnImpl (SA1 const &argv) |
Variables | |
::BLOCXX_NAMESPACE::GlobalPtr < ExecMockObject, Impl::NullFactory > | g_execMockObject = BLOCXX_GLOBAL_PTR_INIT |
static char const *const const | currentEnvironment = 0 |
Intended to be used as a parameter to spawn() to indicate that the current environment will be used for the child process. |
BLOCXX_COMMON_API Process::Status BLOCXX_NAMESPACE::Exec::executeProcessAndGatherOutput | ( | char const *const | command[], |
String & | output, | ||
char const *const | envVars[], | ||
const Timeout & | timeout = Timeout::infinite , |
||
int | outputlimit = -1 , |
||
char const * | input = 0 |
||
) |
Execute a command and run feedProcessAndGatherOutput()
on the process.
This function will not search the path for command[0], so the absolute path to the binary should be specified. If the path needs to be searched, you can set command[0] = "/bin/sh"; command[1] = "-c"; and then fill in the rest of the array with the command you wish to execute. Exercise caution when doing this, as you may be creating a security hole.
command | command[0] is the binary to be executed. command[1] .. command[n] are the command line parameters to the command. |
output |
envVars | An EnvVars object that contains the environment variables to pass as the environment to the new process. If envVars doesn't contain any environment variables, then the current process's environment variables will be used. |
timeout |
outputlimit |
input |
ExecErrorException | on error. |
ExecTimeoutException | if the process hasn't finished within timeoutsecs. |
ExecBufferFullException | if the process output exceeds outputlimit bytes. |
Definition at line 263 of file Exec.cpp.
References feedProcessAndGatherOutput(), g_execMockObject, and spawn().
Referenced by executeProcessAndGatherOutput().
BLOCXX_COMMON_API void BLOCXX_NAMESPACE::Exec::executeProcessAndGatherOutput | ( | const Array< String > & | command, |
String & | output, | ||
int & | processstatus, | ||
int | timeoutsecs, | ||
int | outputlimit, | ||
const String & | input | ||
) |
Definition at line 300 of file Exec.cpp.
References BLOCXX_NAMESPACE::Timeout::relative().
Process::Status BLOCXX_NAMESPACE::Exec::executeProcessAndGatherOutput | ( | SA1 const & | command, |
S1 & | output, | ||
const Timeout & | timeout, | ||
int | outputlimit, | ||
S2 const & | input | ||
) |
Version of executeProcessAndGatherOutput()
that passes the current process's environment to the child process.
Definition at line 576 of file Exec.hpp.
References BLOCXX_NAMESPACE::String::c_str(), currentEnvironment, executeProcessAndGatherOutput(), BLOCXX_NAMESPACE::Cstr::CstrArr< SA >::sarr, and BLOCXX_NAMESPACE::Cstr::to_char_ptr().
Process::Status BLOCXX_NAMESPACE::Exec::executeProcessAndGatherOutput | ( | SA1 const & | command, |
S1 & | output, | ||
S1 & | erroutput, | ||
const Timeout & | timeout, | ||
int | outputlimit, | ||
S2 const & | input | ||
) |
Version of executeProcessAndGatherOutput()
that passes the current process's environment to the child process and separates STDOUT and STDERR.
Definition at line 604 of file Exec.hpp.
References BLOCXX_NAMESPACE::String::c_str(), currentEnvironment, executeProcessAndGatherOutput(), BLOCXX_NAMESPACE::Cstr::CstrArr< SA >::sarr, and BLOCXX_NAMESPACE::Cstr::to_char_ptr().
Process::Status BLOCXX_NAMESPACE::Exec::executeProcessAndGatherOutput | ( | SA1 const & | command, |
S1 & | output, | ||
const Timeout & | timeout = Timeout::infinite , |
||
int | outputlimit = -1 |
||
) |
Version of executeProcessAndGatherOutput()
that passes the current process's environment to the child process.
Definition at line 633 of file Exec.hpp.
References BLOCXX_NAMESPACE::String::c_str(), currentEnvironment, executeProcessAndGatherOutput(), and BLOCXX_NAMESPACE::Cstr::CstrArr< SA >::sarr.
Process::Status BLOCXX_NAMESPACE::Exec::executeProcessAndGatherOutput | ( | SA1 const & | command, |
S1 & | output, | ||
S1 & | erroutput, | ||
const Timeout & | timeout = Timeout::infinite , |
||
int | outputlimit = -1 |
||
) |
Version of executeProcessAndGatherOutput()
that passes the current process's environment to the child process and collects STDOUT and STDERR separately.
Definition at line 660 of file Exec.hpp.
References BLOCXX_NAMESPACE::String::c_str(), currentEnvironment, executeProcessAndGatherOutput(), and BLOCXX_NAMESPACE::Cstr::CstrArr< SA >::sarr.
Process::Status BLOCXX_NAMESPACE::Exec::executeProcessAndGatherOutput | ( | SA1 const & | command, |
S1 & | output, | ||
SA2 const & | envp, | ||
const Timeout & | timeout, | ||
int | outputlimit, | ||
S2 const & | input | ||
) |
Variant of executeProcessAndGatherOutput
that allows command and envp to have arbitrary string-array-like types and output to have an arbitrary string-like type.
If command or envp are of type StringArray a terminating null is not necessary.
Cstr::to_char_ptr
is defined.Cstr::CstrArr
class template are defined for both types SA1 and SA2. Definition at line 698 of file Exec.hpp.
References BLOCXX_NAMESPACE::String::c_str(), executeProcessAndGatherOutput(), BLOCXX_NAMESPACE::Cstr::CstrArr< SA >::sarr, and BLOCXX_NAMESPACE::Cstr::to_char_ptr().
BLOCXX_COMMON_API Process::Status BLOCXX_NAMESPACE::Exec::executeProcessAndGatherOutput | ( | char const *const | command[], |
String & | output, | ||
String & | erroutput, | ||
char const *const | envVars[], | ||
const Timeout & | timeout = Timeout::infinite , |
||
int | outputLimit = -1 , |
||
char const * | input = 0 |
||
) |
Execute a command and run feedProcessAndGatherOutput()
on the process.
This function will not search the path for command[0], so the absolute path to the binary should be specified. If the path needs to be searched, you can set command[0] = "/bin/sh"; command[1] = "-c"; and then fill in the rest of the array with the command you wish to execute. Exercise caution when doing this, as you may be creating a security hole.
command | command[0] is the binary to be executed. command[1] .. command[n] are the command line parameters to the command. |
output |
erroutput |
envVars | An EnvVars object that contains the environment variables to pass as the environment to the new process. If envVars doesn't contain any environment variables, then the current process's environment variables will be used. |
timeout |
outputlimit |
input |
ExecErrorException | on error. |
ExecTimeoutException | if the process hasn't finished within timeoutsecs. |
ExecBufferFullException | if the process output exceeds outputlimit bytes. |
Definition at line 280 of file Exec.cpp.
References feedProcessAndGatherOutput(), g_execMockObject, and spawn().
Process::Status BLOCXX_NAMESPACE::Exec::executeProcessAndGatherOutput | ( | SA1 const & | command, |
S1 & | output, | ||
S1 & | erroutput, | ||
SA2 const & | envp, | ||
const Timeout & | timeout, | ||
int | outputlimit, | ||
S2 const & | input | ||
) |
Variant of executeProcessAndGatherOutput
that allows command and envp to have arbitrary string-array-like types and output to have an arbitrary string-like type.
It also collects STDOUT and STDERR separately. If command or envp are of type StringArray a terminating null is not necessary.
Cstr::to_char_ptr
is defined.Cstr::CstrArr
class template are defined for both types SA1 and SA2. Definition at line 736 of file Exec.hpp.
References BLOCXX_NAMESPACE::String::c_str(), executeProcessAndGatherOutput(), BLOCXX_NAMESPACE::Cstr::CstrArr< SA >::sarr, and BLOCXX_NAMESPACE::Cstr::to_char_ptr().
Process::Status BLOCXX_NAMESPACE::Exec::executeProcessAndGatherOutput | ( | SA1 const & | command, |
S1 & | output, | ||
S1 & | erroutput, | ||
SA2 const & | envp, | ||
const Timeout & | timeout = Timeout::infinite , |
||
int | outputlimit = -1 |
||
) |
Version of executeProcessAndGatherOutput()
that passes no input to the process.
STDOUT and STDERR are collected separately.
Definition at line 766 of file Exec.hpp.
References executeProcessAndGatherOutput().
BLOCXX_COMMON_API Process::Status BLOCXX_NAMESPACE::Exec::feedProcessAndGatherOutput | ( | ProcessRef const & | proc, |
String & | output, | ||
Timeout const & | timeout = Timeout::infinite , |
||
int | outputlimit = -1 , |
||
String const & | input = String() |
||
) |
Send input to a process, collect the output, and wait for it to exit.
The function returns when the process exits. In the case that the child process doesn't exit, if a timout is specified, then an ExecTimeoutException
is thrown. If the process outputs more bytes than outputlimit, an ExecBufferFullException
is thrown.
If the process does not terminate by itself, or if an exception is thrown because a limit has been reached (time or output), then Process::waitCloseTerm() is called with default arguments to force termination.
proc | The object managing the process. |
output | Process output is appended to this string. |
timeout | The interval to wait for the process to exit. If the process hasn't exited after the timeout, an ExecTimeoutException will be thrown, and the process will be killed. Output from a process can reset a relative with reset timeout. |
outputlimit | The maximum size of the parameter output, in order to constrain possible memory usage. If the process outputs more data than will fit into output, then an ExecBufferFullException is thrown, and the process will be killed. If outputlimit < 0, the limit will be infinite, and an ExecBufferFullException will not be thrown. |
input | Data to write to the child's stdin. After the data has been written, stdin is closed. |
ExecErrorException | on error. |
ExecTimeoutException | if the process hasn't finished within timeoutsecs. |
ExecBufferFullException | if the process output exceeds outputlimit bytes. |
Definition at line 320 of file Exec.cpp.
References processInputOutput().
Referenced by executeProcessAndGatherOutput().
BLOCXX_COMMON_API Process::Status BLOCXX_NAMESPACE::Exec::feedProcessAndGatherOutput | ( | ProcessRef const & | proc, |
String & | output, | ||
String & | erroutput, | ||
Timeout const & | timeout = Timeout::infinite , |
||
int | outputLimit = -1 , |
||
String const & | input = String() |
||
) |
Send input to a process, collect STDOUT and STDERR, and wait for it to exit.
The function returns when the process exits. In the case that the child process doesn't exit, if a timout is specified, then an ExecTimeoutException
is thrown. If the process outputs more bytes than outputlimit on STDOUT or STDERR, an ExecBufferFullException
is thrown.
If the process does not terminate by itself, or if an exception is thrown because a limit has been reached (time or output), then Process::waitCloseTerm() is called with default arguments to force termination.
proc | The object managing the process. |
output | Process STDOUT is appended to this string. |
erroutut | Process STDERR is appended to this string. |
timeout | The interval to wait for the process to exit. If the process hasn't exited after the timeout, an ExecTimeoutException will be thrown, and the process will be killed. Output from a process can reset a relative with reset timeout. |
outputlimit | The maximum size of the parameter output, in order to constrain possible memory usage. If the process outputs more data than will fit into output, then an ExecBufferFullException is thrown, and the process will be killed. If outputlimit < 0, the limit will be infinite, and an ExecBufferFullException will not be thrown. |
input | Data to write to the child's stdin. After the data has been written, stdin is closed. |
ExecErrorException | on error. |
ExecTimeoutException | if the process hasn't finished within timeoutsecs. |
ExecBufferFullException | if the process output exceeds outputlimit bytes. |
Definition at line 337 of file Exec.cpp.
References processInputOutput().
BLOCXX_COMMON_API void BLOCXX_NAMESPACE::Exec::gatherOutput | ( | String & | output, |
const ProcessRef & | proc, | ||
const Timeout & | timeout = Timeout::infinite , |
||
int | outputlimit = -1 |
||
) |
Wait for output from a child process.
The function returns when the process exits. In the case that the child process doesn't exit, if a timout is specified, then an ExecTimeoutException is thrown. If the process outputs more bytes than outputlimit, an ExecBufferFullException is thrown.
output | An out parameter, the process output will be appended to this string. |
proc | The connection to the child process. |
timeout | Specifies the interval to wait for the process to exit. If the process hasn't exited after the timeout, an ExecTimeoutException will be thrown. Output from a process can reset a relative with reset timeout. |
outputlimit | Specifies the maximum size of the parameter output, in order to constrain possible memory usage. If the process outputs more data than will fit into output, then an ExecBufferFullException is thrown. If outputlimit < 0, the limit will be infinite, and an ExecBufferFullException will never be thrown. |
ProcessError | on error. |
ProcessTimeout | if the process hasn't finished within timeoutsecs. |
ProcessBufferFull | if the process output exceeds outputlimit bytes. |
void BLOCXX_NAMESPACE::Exec::gatherOutput | ( | String & | output, |
const ProcessRef & | proc, | ||
int | timeoutSecs, | ||
int | outputLimit | ||
) |
BLOCXX_COMMON_API void BLOCXX_NAMESPACE::Exec::processInputOutput | ( | OutputCallback & | output, |
Array< ProcessRef > & | procs, | ||
InputCallback & | input, | ||
const Timeout & | timeout = Timeout::infinite |
||
) |
Send input and wait for output from child processes.
The function returns when the processes have exited. In the case that a child process doesn't exit, if a timout is specified, then an ExecTimeoutException is thrown. If an exception is thrown by the OutputCallback or InputCallback, it will not be caught.
output | A callback, whenever data is received from a process, it will be passed to output.handleData(). |
procs | The connections to the child processes. |
timeout | Specifies the interval to wait for all the processes to exit. If the timeout expires, an ExecTimeoutException will be thrown. Output from a process can reset a relative with reset timeout. |
input | Callback to provide data to be written to the process(es) standard input. input.getData() will be called once for each stream, and subsequently once every time data has been written to a process. output.handleData() may also provide input data via the inputBuffer parameter, it is called every time data is read from a process. |
ExecErrorException | on error. |
ExecTimeoutException | if the process hasn't finished within timeoutSecs. |
Definition at line 418 of file Exec.cpp.
References i, and BLOCXX_NAMESPACE::Array< T >::size().
Referenced by feedProcessAndGatherOutput().
BLOCXX_COMMON_API void BLOCXX_NAMESPACE::Exec::processInputOutput | ( | const String & | input, |
String & | output, | ||
const ProcessRef & | process, | ||
const Timeout & | timeout, | ||
int | outputLimit | ||
) |
BLOCXX_COMMON_API int BLOCXX_NAMESPACE::Exec::safeSystem | ( | const Array< String > & | command, |
const char *const | envp[] = 0 |
||
) |
ProcessRef BLOCXX_NAMESPACE::Exec::spawn | ( | S const & | exec_path, |
SA1 const & | argv, | ||
SA2 const & | envp, | ||
PreExec & | pre_exec | ||
) |
Variant of spawn
that allows exec_path to have an arbitrary string-like type, and argv and envp to have arbitrary string-array-like types.
If argv or envp are of type StringArray a terminating null is not necessary.
Cstr::to_char_ptr
is defined.Cstr::CstrArr
class template are defined for both types SA1 and SA2. Definition at line 247 of file Exec.hpp.
References BLOCXX_NAMESPACE::Cstr::CstrArr< SA >::sarr, spawn(), and BLOCXX_NAMESPACE::Cstr::to_char_ptr().
ProcessRef BLOCXX_NAMESPACE::Exec::spawn | ( | SA1 const & | argv, |
SA2 const & | envp | ||
) |
Variant of spawn
that uses StandardPreExec
and argv and envp to have arbitrary string-array-like types.
Cstr::CstrArr
class template are defined for both types SA1 and SA2. Definition at line 272 of file Exec.hpp.
References BLOCXX_NAMESPACE::Cstr::CstrArr< SA >::sarr, and spawn().
BLOCXX_COMMON_API ProcessRef BLOCXX_NAMESPACE::Exec::spawn | ( | char const * | exec_path, |
char const *const | argv[], | ||
char const *const | envp[], | ||
PreExec & | pre_exec | ||
) |
Run the executable exec_path in a child process, with argv for the program arguments and envp for the environment.
exec_path | Absolute path of the executable to run in the child process. |
argv | Null-terminated argument list for the child process. If argv is null or the empty sequence (argv[0] is null), then it is replaced with a sequence containing only exec_path. |
envp | The null-terminated environment for the child process. If null then the caller's environment is used. It is recommended that envp be constructed by starting with Secure::minimal_environment() and adding only those additional environment variables known to be needed. |
pre_exec | Specifies what action to take in the child process between fork and exec . |
Definition at line 139 of file Exec.cpp.
References BLOCXX_NAMESPACE::WaitpidThreadFix::spawnProcess().
Referenced by executeProcessAndGatherOutput(), and spawn().
ProcessRef BLOCXX_NAMESPACE::Exec::spawn | ( | SA1 const & | argv | ) |
Definition at line 282 of file Exec.hpp.
References currentEnvironment, and spawn().
BLOCXX_COMMON_API ProcessRef BLOCXX_NAMESPACE::Exec::spawn | ( | char const *const | argv[], |
char const *const | envp[] | ||
) |
ProcessRef BLOCXX_NAMESPACE::Exec::spawnImpl | ( | S const & | exec_path, |
SA1 const & | argv, | ||
SA2 const & | envp, | ||
PreExec & | pre_exec | ||
) |
Variant of spawnImpl
that allows exec_path to have an arbitrary string-like type, and argv and envp to have arbitrary string-array-like types.
If argv or envp are of type StringArray a terminating null is not necessary.
Cstr::to_char_ptr
is defined.Cstr::CstrArr
class template are defined for both types SA1 and SA2. Definition at line 70 of file WaitpidThreadFixFwd.hpp.
References BLOCXX_NAMESPACE::Cstr::CstrArr< SA >::sarr, spawnImpl(), and BLOCXX_NAMESPACE::Cstr::to_char_ptr().
ProcessRef BLOCXX_NAMESPACE::Exec::spawnImpl | ( | char const * | exec_path, |
char const *const | argv[], | ||
char const *const | envp[], | ||
PreExec & | pre_exec | ||
) |
Definition at line 125 of file Exec.cpp.
Referenced by spawnImpl().
ProcessRef BLOCXX_NAMESPACE::Exec::spawnImpl | ( | char const *const | argv[], |
char const *const | envp[] | ||
) |
Variant of spawnImpl that uses StandardPreExec
.
ProcessRef BLOCXX_NAMESPACE::Exec::spawnImpl | ( | SA1 const & | argv | ) |
Definition at line 105 of file WaitpidThreadFixFwd.hpp.
References currentEnvironment, and spawnImpl().
ProcessRef BLOCXX_NAMESPACE::Exec::spawnImpl | ( | SA1 const & | argv, |
SA2 const & | envp | ||
) |
Variant of spawnImpl
that uses StandardPreExec
and argv and envp to have arbitrary string-array-like types.
Cstr::CstrArr
class template are defined for both types SA1 and SA2. Definition at line 95 of file WaitpidThreadFixFwd.hpp.
References BLOCXX_NAMESPACE::Cstr::CstrArr< SA >::sarr, and spawnImpl().
BLOCXX_COMMON_API Process::Status BLOCXX_NAMESPACE::Exec::system | ( | const Array< String > & | command, |
const char *const | envp[] = 0 , |
||
const Timeout & | = Timeout::infinite |
||
) |
Execute a command.
The command will inherit stdin, STDOUT, and STDERR from the parent process. This function will not search the path for command[0], so the absolute path to the binary should be specified. If the path needs to be searched, you can set command[0] = "/bin/sh"; command[1] = "-c"; and then fill in the rest of the array with the command you wish to execute. This function blocks until the child process exits. Use a timeout or be careful that the command you run doesn't hang.
command | command[0] is the binary to be executed. command[1] .. command[n] are the command line parameters to the command. |
envp | an array of strings of the form "key=value", which are passed as environment to the new program. envp must be terminated by a null pointer. envp may be 0, in which case the current process's environment variables will be used. |
timeout | How long to wait for the process to exit. |
ExecErrorException | on error |
Definition at line 100 of file Exec.cpp.
Referenced by BLOCXX_NAMESPACE::StackTrace::getStackTrace(), and system().
Process::Status BLOCXX_NAMESPACE::Exec::system | ( | const SA1 & | command, |
const SA2 & | envVars, | ||
const Timeout & | timeout = Timeout::infinite |
||
) |
Definition at line 88 of file Exec.hpp.
References BLOCXX_NAMESPACE::Cstr::CstrArr< SA >::sarr, and system().
char const* const const BLOCXX_NAMESPACE::Exec::currentEnvironment = 0 [static] |
Intended to be used as a parameter to spawn() to indicate that the current environment will be used for the child process.
Definition at line 205 of file Exec.hpp.
Referenced by executeProcessAndGatherOutput(), spawn(), and spawnImpl().
::BLOCXX_NAMESPACE::GlobalPtr<ExecMockObject, Impl::NullFactory> BLOCXX_NAMESPACE::Exec::g_execMockObject = BLOCXX_GLOBAL_PTR_INIT |
Definition at line 96 of file Exec.cpp.
Referenced by executeProcessAndGatherOutput().