## NAME

ACE_Process_Manager - Manages a pool of processs.

## SYNOPSIS

    #include <ace/Process_Manager.h>

    class ACE_Process_Manager
    {
      public:
        friend class ACE_Process_Control;
        enum{ DEFAULT_SIZE = 100 };
        ACE_Process_Manager (
            size_t size = ACE_Process_Manager::DEFAULT_SIZE
            );
        ~ACE_Process_Manager (void);
        int open (size_t size = DEFAULT_SIZE);
        int close (void);
        pid_t spawn (ACE_Process_Options &options);
        int spawn_n (size_t n, ACE_Process_Options &options);
        int wait (ACE_Time_Value *timeout = 0);
        int terminate (pid_t pid);
        int remove (pid_t pid);
        int reap (
            pid_t pid = -1,
            int *stat_loc = 0,
            int options = WNOHANG
            );
        void dump (void) const;
        ACE_ALLOC_HOOK_DECLARE;
      private:
        int resize (size_t);
        int find_proc (pid_t p_id);
        int insert_proc (pid_t p_id);
        int append_proc (pid_t p_id);
        ACE_Process_Descriptor *proc_table_;
        size_t max_table_size_;
        size_t current_count_;
        ACE_Thread_Mutex lock_;
        ACE_Condition_Thread_Mutex zero_cond_;
    };

## DESCRIPTION

This class allows operations on groups of processs atomically.

## Initialization and termination methods.

    ACE_Process_Manager (size_t size = ACE_Process_Manager::DEFAULT_SIZE);

    ~ACE_Process_Manager (void);

    int open (size_t size = DEFAULT_SIZE);

Initialize the manager with room for SIZE processs.

    int close (void);

Release all resources.

    pid_t spawn (ACE_Process_Options &options);

Create a new process using ACE_Process::start (`options`).

Returns: on success a unique group id that can be used to control other processs added to the same group. On failure, returns -1.

    int spawn_n (size_t n, ACE_Process_Options &options);

Create N new processs.

Returns: on success a unique group id that can be used to control all of the processs in the same group. On failure, returns -1.

    int wait (ACE_Time_Value *timeout = 0);

Block until there are no more processs running or `timeout` expires. Returns 0 on success and -1 on failure.

    int terminate (pid_t pid);

Terminate a single process with id `pid`.

    int remove (pid_t pid);

Remove process `pid` from the table. This is typically called by a signal handler that has just reaped `SIGCHILD`.

    int reap (pid_t pid = -1, int *stat_loc = 0, int options = WNOHANG);

Reap a `SIGCHLD` by calling `ACE_OS::waitpid`.

    void dump (void) const;

Dump the state of an object.

    ACE_ALLOC_HOOK_DECLARE;

Declare the dynamic allocation hooks.

## ACE_Thread_Mutex and condition variable for synchronizing termination.

    ACE_Thread_Mutex lock_;

    ACE_Condition_Thread_Mutex zero_cond_;

## AUTHOR

Doug Schmidt

## LIBRARY

ace