Classes | |
class | OutputCallback |
class | InputCallback |
class | ProcessStatus |
Enumerations | |
enum | EOutputSource { E_STDOUT, E_STDERR } |
enum | EProcessRunning { E_PROCESS_RUNNING, E_PROCESS_EXITED } |
Functions | |
int | safeSystem (const Array< String > &command, const EnvVars &envVars) |
Execute a command. | |
int | safeSystem (const Array< String > &command, const char *const envp[]=0) |
Execute a command. | |
PopenStreams | safePopen (const Array< String > &command, const String &initialInput) |
The use of initialInput is deprecated, because it's not safe to use it in a portable manner. | |
PopenStreams | safePopen (const Array< String > &command, const EnvVars &envVars) |
Execute a command. | |
PopenStreams | safePopen (const Array< String > &command, const char *const envp[]=0) |
Execute a command. | |
void | executeProcessAndGatherOutput (const Array< String > &command, String &output, int &processstatus, int timeoutsecs=INFINITE_TIMEOUT, int outputlimit=-1, const String &input=String()) |
Run a process, collect the output, and wait for it to exit. | |
void | executeProcessAndGatherOutput (const Array< String > &command, String &output, int &processstatus, const EnvVars &envVars, int timeoutsecs=INFINITE_TIMEOUT, int outputlimit=-1, const String &input=String()) |
Run a process, collect the output, and wait for it to exit. | |
void | gatherOutput (String &output, PopenStreams &streams, int &processstatus, int timeoutsecs=INFINITE_TIMEOUT, int outputlimit=-1) |
Wait for output from a child process. | |
void | processInputOutput (OutputCallback &output, Array< PopenStreams > &streams, Array< ProcessStatus > &processStatuses, InputCallback &input, int timeoutSecs=INFINITE_TIMEOUT) |
Send input and wait for output from child processes. | |
Variables | |
const int | INFINITE_TIMEOUT = -1 |
|
Definition at line 323 of file OW_Exec.hpp. |
|
Definition at line 351 of file OW_Exec.hpp. |
|
Run 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. 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. If the process does not terminate by itself, or if an exception is thrown because a limit has been reached (time or output), then the the following steps will be taken to attempt to terminate the child process. 1. The input and output pipes will be closed. This may cause the child to get a SIGPIPE which may terminate it. 2. If the child still hasn't terminated after 10 seconds, a SIGTERM is sent. 3. If the child still hasn't terminated after 10 seconds, a SIGKILL is sent.
Definition at line 860 of file OW_Exec.cpp. References command, processInputOutput(), OW_NAMESPACE::Array< T >::push_back(), and safePopen(). |
|
Run 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. 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. If the process does not terminate by itself, or if an exception is thrown because a limit has been reached (time or output), then the the following steps will be taken to attempt to terminate the child process. 1. The input and output pipes will be closed. This may cause the child to get a SIGPIPE which may terminate it. 2. If the child still hasn't terminated after 10 seconds, a SIGTERM is sent. 3. If the child still hasn't terminated after 10 seconds, a SIGKILL is sent.
Definition at line 851 of file OW_Exec.cpp. References command. |
|
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.
Definition at line 891 of file OW_Exec.cpp. References processInputOutput(), and OW_NAMESPACE::Array< T >::push_back(). Referenced by OW_NAMESPACE::runHelper(). |
|
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.
Definition at line 952 of file OW_Exec.cpp. References OW_NAMESPACE::Array< T >::clear(), OW_NAMESPACE::Exec::InputCallback::getData(), OW_NAMESPACE::Array< T >::resize(), and OW_NAMESPACE::Array< T >::size(). Referenced by executeProcessAndGatherOutput(), and gatherOutput(). |
|
Execute a command. The command's stdin, stdout, and stderr will be connected via pipes to the parent process that can be accessed from the return value. 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 does *not* block until the child process exits. If the binary specified in command[0] does not exist, execv() will fail, and the return code of the sub-process will be 127. However, this is not distinguishable from the command process returning 127.
Definition at line 589 of file OW_Exec.cpp. |
|
Execute a command. The command's stdin, stdout, and stderr will be connected via pipes to the parent process that can be accessed from the return value. 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 does *not* block until the child process exits. If the binary specified in command[0] does not exist, execv() will fail, and the return code of the sub-process will be 127. However, this is not distinguishable from the command process returning 127.
Definition at line 581 of file OW_Exec.cpp. References command, OW_NAMESPACE::EnvVars::getenvp(), safePopen(), and OW_NAMESPACE::EnvVars::size(). |
|
The use of initialInput is deprecated, because it's not safe to use it in a portable manner. Either use the input parameter to processInputOutput or do it manually (not that you must be careful not to cause a deadlock). Definition at line 563 of file OW_Exec.cpp. References OW_NAMESPACE::String::c_str(), command, OW_NAMESPACE::PopenStreams::in(), OW_NAMESPACE::String::length(), and OW_THROW_ERRNO_MSG. Referenced by executeProcessAndGatherOutput(), OW_NAMESPACE::runHelper(), and safePopen(). |
|
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. Be careful that the command you run doesn't hang. It is recommended to use executeProcessAndGatherOutput() if the command is untrusted.
Definition at line 449 of file OW_Exec.cpp. References command. |
|
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. Be careful that the command you run doesn't hang. It is recommended to use executeProcessAndGatherOutput() if the command is untrusted.
Definition at line 441 of file OW_Exec.cpp. References command, OW_NAMESPACE::EnvVars::getenvp(), and OW_NAMESPACE::EnvVars::size(). |
|
Definition at line 291 of file OW_Exec.hpp. Referenced by OW_NAMESPACE::Select::selectRWPoll(), and OW_NAMESPACE::Select::selectRWSelect(). |