Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# ACE_Process Class Reference

Process. More...

`#include <Process.h>`

Inheritance diagram for ACE_Process:

[legend]
Collaboration diagram for ACE_Process:

[legend]
List of all members.

## Public Methods
| ACE_Process (void)
| Default construction. Must use <ACE_Process::spawn> to start. More...
virtual | ~ACE_Process (void)
| Destructor. More...
virtual int | prepare (ACE_Process_Options &options)
| Called just before <ACE_OS::fork> in the <spawn>. More...
virtual pid_t | spawn (ACE_Process_Options &options)
| Launch a new process as described by <options>. More...
virtual void | parent (pid_t child)
| Called just after <ACE_OS::fork> in the parent's context, if the <fork> succeeds. The default is to do nothing. More...
virtual void | child (pid_t parent)
| Called just after <ACE_OS::fork> in the child's context. More...
virtual void | unmanage (void)
| Called by a <Process_Manager> that is removing this Process from its table of managed Processes. Default is to do nothing. More...
pid_t | wait (ACE_exitcode *status=0, int wait_options=0)
| Wait for the process we've created to exit. More...
pid_t | wait (const ACE_Time_Value &tv, ACE_exitcode *status=0)
| Timed wait for the process we've created to exit. More...
int | kill (int signum=SIGINT)
| Send the process a signal. This is only portable to operating systems that support signals, such as UNIX/POSIX. More...
int | terminate (void)
| Terminate the process abruptly using <ACE::terminate_process>. More...
pid_t | getpid (void) const
| Return the process id of the new child process. More...
ACE_HANDLE | gethandle (void) const
| Return the handle of the process, if it has one. More...
int | running (void) const
| Return 1 if running; 0 otherwise. More...
int | exit_code (void) const
| Return the Process' exit code. More...
void | exit_code (int code)
| Set the Process' exit code (completely unrelated to whether the Process has actually exited)! More...
void | close_dup_handles (void)
| Close all the handles in the set obtained from the ACE_Process_Options::dup_handles object used to spawn the process. More...
void | close_passed_handles (void)
| Close all the handles in the set obtained from the ACE_Process_Options::passed_handles object used to spawn the process. More...
PROCESS_INFORMATION | process_info (void)
## Protected Attributes
PROCESS_INFORMATION | process_info_
int | exit_code_
ACE_Handle_Set | handles_passed_
| Set of handles that were passed to the child process. More...
ACE_Handle_Set | dup_handles_
| Handle duplicates made for the child process. More...

## Detailed Description

Process.

A Portable encapsulation for creating new processes. Notice that on UNIX platforms, if the <setenv> is used, the <spawn> is using the <execve> system call. It means that the <command_line> should include a full path to the program file (<execve> does not search the PATH). If <setenv> is not used then, the <spawn> is using the <execvp> which searches for the program file in the PATH variable.

## Constructor & Destructor Documentation

ACE_Process::ACE_Process | ( | void |  | ) |

| Default construction. Must use <ACE_Process::spawn> to start.

ACE_Process::~ACE_Process | ( | void |  | ) | `[virtual]`

| Destructor.

## Member Function Documentation

void ACE_Process::child | ( | pid_t | parent | ) | `[virtual]`

| Called just after <ACE_OS::fork> in the child's context. The default does nothing. This function is *not* called on Win32 because the process-creation scheme does not allow it.

void ACE_Process::close_dup_handles | ( | void |  | ) |

| Close all the handles in the set obtained from the ACE_Process_Options::dup_handles object used to spawn the process.

void ACE_Process::close_passed_handles | ( | void |  | ) |

| Close all the handles in the set obtained from the ACE_Process_Options::passed_handles object used to spawn the process.

ACE_INLINE void ACE_Process::exit_code | ( | int | code | ) |

| Set the Process' exit code (completely unrelated to whether the Process has actually exited)!

ACE_INLINE int ACE_Process::exit_code | ( | void |  | ) | const

| Return the Process' exit code.

ACE_INLINE ACE_HANDLE ACE_Process::gethandle | ( | void |  | ) | const

| Return the handle of the process, if it has one.

ACE_INLINE pid_t ACE_Process::getpid | ( | void |  | ) | const

| Return the process id of the new child process.

ACE_INLINE int ACE_Process::kill | ( | int | signum = SIGINT | ) |

| Send the process a signal. This is only portable to operating systems that support signals, such as UNIX/POSIX.

void ACE_Process::parent | ( | pid_t | child | ) | `[virtual]`

| Called just after <ACE_OS::fork> in the parent's context, if the <fork> succeeds. The default is to do nothing.

int ACE_Process::prepare | ( | ACE_Process_Options & | options | ) | `[virtual]`

| Called just before <ACE_OS::fork> in the <spawn>. If this returns non-zero, the <spawn> is aborted (and returns ACE_INVALID_PID). The default simply returns zero.

PROCESS_INFORMATION ACE_Process::process_info | ( | void |  | ) |

int ACE_Process::running | ( | void |  | ) | const

| Return 1 if running; 0 otherwise.

pid_t ACE_Process::spawn | ( | ACE_Process_Options & | options | ) | `[virtual]`

| Launch a new process as described by <options>. Returns the process id of the newly spawned child on success or -1 on failure.

ACE_INLINE int ACE_Process::terminate | ( | void |  | ) |

| 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]`

| Called by a <Process_Manager> that is removing this Process from its table of managed Processes. Default is to do nothing. Reimplemented in ACE_Managed_Process.

pid_t ACE_Process::wait | ( | const ACE_Time_Value & | tv,
|  | ACE_exitcode * | status = 0
| ) |

| Timed wait for the process we've created to exit. A return value of -1 indicates that the something failed; 0 indicates that a timeout occurred. Otherwise, the child's process id is returned. If <status> != 0, it points to an integer where the function stores the child's exit status. NOTE: on UNIX platforms this function uses <ualarm>, i.e., it overwrites any existing alarm. In addition, it steals all <SIGCHLD>s during the timeout period, which will break another <ACE_Process_Manager> in the same process that's expecting <SIGCHLD> to kick off process reaping.

ACE_INLINE pid_t ACE_Process::wait | ( | ACE_exitcode * | status = 0,
|  | int | wait_options = 0
| ) |

| Wait for the process we've created to exit. If <status> != 0, it points to an integer where the function store the exit status of child process to. If <wait_options> == <WNOHANG> then return 0 and don't block if the child process hasn't exited yet. A return value of -1 represents the <wait> operation failed, otherwise, the child process id is returned.

## Member Data Documentation

ACE_Handle_Set ACE_Process::dup_handles_`[protected]`

| Handle duplicates made for the child process.

int ACE_Process::exit_code_`[protected]`

ACE_Handle_Set ACE_Process::handles_passed_`[protected]`

| 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:

- Process.h
- Process.cpp
- Process.i