|
|
| ACE_Process_Manager (size_t size=ACE_Process_Manager::DEFAULT_SIZE, ACE_Reactor *reactor=0) |
|
int | open (size_t size=ACE_Process_Manager::DEFAULT_SIZE, ACE_Reactor *r=0) |
|
int | close () |
| Release all resources. Do not wait for processes to exit.
|
|
virtual | ~ACE_Process_Manager () |
|
|
pid_t | spawn (ACE_Process *proc, ACE_Process_Options &options, ACE_Event_Handler *event_handler=0) |
|
pid_t | spawn (ACE_Process_Options &options, ACE_Event_Handler *event_handler=0) |
|
int | spawn_n (size_t n, ACE_Process_Options &options, pid_t *child_pids=0, ACE_Event_Handler *event_Handler=0) |
|
|
int | terminate (pid_t pid) |
|
int | terminate (pid_t pid, int sig) |
|
int | wait (const ACE_Time_Value &timeout=ACE_Time_Value::max_time) |
|
template<class Rep , class Period > |
int | wait (const std::chrono::duration< Rep, Period > &timeout) |
|
pid_t | wait (pid_t pid, const ACE_Time_Value &timeout, ACE_exitcode *status=0) |
|
template<class Rep , class Period > |
pid_t | wait (pid_t pid, const std::chrono::duration< Rep, Period > &timeout, ACE_exitcode *status=0) |
|
pid_t | wait (pid_t pid, ACE_exitcode *status=0) |
|
|
typedef std::atomic< Reference_Count > | Atomic_Reference_Count |
| Typedef for implementation of reference counting.
|
|
enum | {
LO_PRIORITY = 0
, HI_PRIORITY = 10
, NULL_MASK = 0
, READ_MASK = (1 << 0)
,
WRITE_MASK = (1 << 1)
, EXCEPT_MASK = (1 << 2)
, ACCEPT_MASK = (1 << 3)
, CONNECT_MASK = (1 << 4)
,
TIMER_MASK = (1 << 5)
, QOS_MASK = (1 << 6)
, GROUP_QOS_MASK = (1 << 7)
, SIGNAL_MASK = (1 << 8)
,
ALL_EVENTS_MASK
, RWE_MASK
, DONT_CALL = (1 << 9)
} |
|
enum | { ACE_EVENT_HANDLER_NOT_RESUMED = -1
, ACE_REACTOR_RESUMES_HANDLER = 0
, ACE_APPLICATION_RESUMES_HANDLER
} |
|
typedef long | Reference_Count |
| Reference count type.
|
|
| ACE_Event_Handler (ACE_Reactor *=nullptr, int priority=ACE_Event_Handler::LO_PRIORITY) |
| Force ACE_Event_Handler to be an abstract base class.
|
|
virtual | ~ACE_Event_Handler ()=default |
| Destructor is virtual to enable proper cleanup.
|
|
virtual ACE_HANDLE | get_handle () const |
| Get the I/O handle.
|
|
virtual void | set_handle (ACE_HANDLE) |
| Set the I/O handle.
|
|
virtual int | priority () const |
|
virtual void | priority (int priority) |
| Set the priority of the Event_Handler.
|
|
virtual int | handle_input (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
| Called when input events occur (e.g., connection or data).
|
|
virtual int | handle_output (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
|
virtual int | handle_exception (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
| Called when an exceptional events occur (e.g., SIGURG).
|
|
virtual int | handle_timeout (const ACE_Time_Value ¤t_time, const void *act=0) |
|
virtual int | handle_exit (ACE_Process *) |
| Called when a process exits.
|
|
virtual int | handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask) |
|
virtual int | resume_handler () |
|
virtual int | handle_qos (ACE_HANDLE=ACE_INVALID_HANDLE) |
|
virtual int | handle_group_qos (ACE_HANDLE=ACE_INVALID_HANDLE) |
|
virtual void | reactor (ACE_Reactor *reactor) |
| Set the event demultiplexors.
|
|
virtual ACE_Reactor * | reactor () const |
| Get the event demultiplexors.
|
|
virtual ACE_Reactor_Timer_Interface * | reactor_timer_interface () const |
| Get only the reactor's timer related interface.
|
|
virtual Reference_Count | add_reference () |
| Increment reference count on the handler.
|
|
virtual Reference_Count | remove_reference () |
| Decrement reference count on the handler.
|
|
Reference_Counting_Policy & | reference_counting_policy () |
| Current Reference_Counting_Policy.
|
|
static ACE_THR_FUNC_RETURN | read_adapter (void *event_handler) |
|
static int | register_stdin_handler (ACE_Event_Handler *eh, ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr, int flags=THR_DETACHED) |
|
static int | remove_stdin_handler (ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr) |
| Performs the inverse of the register_stdin_handler() method.
|
|
Atomic_Reference_Count | reference_count_ |
| Reference count.
|
|
Manages a group of processes.
This class allows applications to control groups of processes, similar to the way ACE_Thread_Manager controls groups of threads. Naturally, it doesn't work at all on platforms, such as VxWorks or pSoS, that don't support multiple processes. There are two main ways of using ACE_Process_Manager, depending on how involved you wish to be with the termination of managed processes. If you want processes to simply go away when they're finished, register the ACE_Process_Manager with an ACE_Reactor that can handle notifications of child process exit:
This class inherits the interface of the abstract ACE_Dumpable class and is instantiated with the imp...
Definition Dump_T.h:39
Manages a group of processes.
Definition Process_Manager.h:97
static ACE_Reactor * instance()
Get pointer to a process-wide ACE_Reactor.
Definition Reactor.cpp:98
In this usage scenario, the ACE_Process_Manager will clean up after any processes that it spawns. (On Unix, this means executing a wait(2) to collect the exit status and avoid zombie processes; on Win32, it means closing the process and thread HANDLEs that are created when CreateProcess is called.)
- Note
- When you register a ACE_Process_Manager with a ACE_Reactor, the reactor's notification pipe is used to help reap the available process exit statuses. Therefore, you must not use a reactor whose notify pipe has been disabled. Here's the sequence of steps used to reap the exit statuses in this case:
- The ACE_Process_Manager registers a signal handler for SIGCHLD.
- The SIGCHLD handler, when invoked, uses the ACE_Reactor's notify() method to inform the ACE_Reactor to wake up.
- The ACE_Reactor calls the ACE_Process_Manager's handle_input() method; this happens synchronously, not in signal context.
- The handle_input() method collects all available exit statuses.
If, on the other hand you want to wait "in line" to handle the terminated process cleanup code, call one of the wait functions whenever there might be managed processes that have exited.
Note that in either case, ACE_Process_Manager allows you to register an ACE_Event_Handler to be called when a specific spawned process exits, or when any process without a specific ACE_Event_Handler exits. When a process exits, the appropriate ACE_Event_Handler's handle_input() method is called; the ACE_HANDLE passed is either the process's HANDLE (on Windows), or its pid cast to an ACE_HANDLE (on POSIX). It is also possible to call the wait() functions even when the ACE_Process_Manager is registered with a reactor.
- Note
- Be aware that the wait functions are "sloppy" on Unix, because there's no good way to wait for a subset of the children of a process. The wait functions may end up collecting the exit status of a process that's not managed by the ACE_Process_Manager whose wait() you invoked. It's best to only use a single ACE_Process_Manager, and to create all subprocesses by calling that manager's spawn() method.
On Unix, this routine is called asynchronously when a SIGCHLD is received. We just tweak the reactor so that it'll call back our <handle_input> function, which allows us to handle Process exits synchronously.
On Win32, this routine is called synchronously, and is passed the HANDLE of the Process that exited, so we can do all our work here
Reimplemented from ACE_Event_Handler.