A portable encapsulation for creating and managing new processes.
More...
#include <Process.h>
A portable encapsulation for creating and managing new processes.
ACE_Process provides a convenient way to:
- Spawn child processes, with convenient hooks for pre- and post-spawn actions
- Check if a spawned process is still running
- Kill a spawned child process
- Wait for a spawned child process to exit.
- See also
- ACE_Process_Options because it is used to pass options when spawning child processes.
-
ACE_Process_Manager for additional ways to manage spawned processes.
ACE_Process::ACE_Process |
( |
void |
| ) |
|
ACE_Process::~ACE_Process |
( |
void |
| ) |
|
|
virtual |
void ACE_Process::child |
( |
pid_t |
parent | ) |
|
|
virtual |
Called back from spawn() in the child's context just after forking. The default does nothing.
- Note
- This function is not called on Windows because the process-creation scheme does not allow it.
void ACE_Process::close_dup_handles |
( |
void |
| ) |
|
void ACE_Process::close_passed_handles |
( |
void |
| ) |
|
Close all the passed handles in the set obtained from the ACE_Process_Options object used to spawn the process.
wchar_t * ACE_Process::convert_env_buffer |
( |
const char * |
env | ) |
const |
|
private |
Return the process's exit code. This method returns the raw exit status returned from system APIs (such as wait()
or waitpid()
). This value is system dependent.
Set this process's exit code. ACE_Process_Manager uses this method to set the exit code after successfully waiting for this process to exit.
ACE_HANDLE ACE_Process::gethandle |
( |
void |
| ) |
const |
|
inline |
Return the handle of the process, if it has one.
pid_t ACE_Process::getpid |
( |
void |
| ) |
const |
|
inline |
Return the process id of the new child process.
int ACE_Process::kill |
( |
int |
signum = SIGINT | ) |
|
|
inline |
Send the process a signal. This only has an effect on operating systems that support signals, such as UNIX/POSIX.
void ACE_Process::parent |
( |
pid_t |
child | ) |
|
|
virtual |
Called back from spawn() in the parent's context just after forking, if the fork succeeds. The default simply returns.
Called back from spawn() just before spawning the child. If this returns non-zero, the spawn is aborted (and returns ACE_INVALID_PID). The default returns zero.
PROCESS_INFORMATION ACE_Process::process_info |
( |
void |
| ) |
|
|
inline |
int ACE_Process::return_value |
( |
void |
| ) |
const |
|
inline |
Return the process's return value. This method returns the actual return value that a child process returns or exits with.
int ACE_Process::running |
( |
void |
| ) |
const |
Return 1 if running; 0 otherwise.
Launch a new process as described by options.
- Return values
-
-1 | on failure; check errno for error code. |
1 | on success if the option avoid_zombies is set. |
other | the process id of the newly spawned child. |
- Note
- The return value 1 may be changed in future versions of ACE to be the process id of the child will be returned regardless of the
avoid_zombies
option.
-
On UNIX platforms, spawn() uses the execvp() system call if ACE_Process_Options::inherit_environment() returns true (which is the default) and execve() if not. Since execve() does not search PATH, the ACE_Process_Options::command_line() should include a full path to the program file.
int ACE_Process::terminate |
( |
void |
| ) |
|
|
inline |
Terminate the process abruptly using ACE::terminate_process(). This call doesn't give the process a chance to cleanup, so use it with caution.
void ACE_Process::unmanage |
( |
void |
| ) |
|
|
virtual |
pid_t ACE_Process::wait |
( |
ACE_exitcode * |
status = 0 , |
|
|
int |
wait_options = 0 |
|
) |
| |
|
inline |
Wait for a previously spawned process to exit.
- status Points to a location to receive the exit status of the spawned process. Ignored if the value is 0.
- wait_options If
WNOHANG
then return 0 and don't block if the child process hasn't exited yet.
- Return values
-
-1 | the wait operation failed; consult errno for details. |
other | the child process id is returned on success. |
Timed wait for a previously spawned process to exit.
- tv A relative amount of time to wait for the process to exit.
- status Points to a location to receive the exit status of the spawned process. Ignored if the value is 0.
- Return values
-
0 | the specified time period elapsed before the process exited. |
-1 | the wait operation failed; consult errno for details. |
other | the child process id is returned on success. |
- Note
- On UNIX platforms this function uses
ualarm()
, i.e., it overwrites any existing alarm. In addition, it steals all SIGCHLD
signals during the timeout period, which will break another ACE_Process_Manager in the same process that's expecting SIGCHLD
to kick off process reaping.
Handle duplicates made for the child process.
Set of handles that were passed to the child process.
PROCESS_INFORMATION ACE_Process::process_info_ |
|
protected |
The documentation for this class was generated from the following files: