#include <ace/Process.h>
class ACE_Process {
public:ACE_Process (void);virtual ~ACE_Process (void);virtual int prepare (ACE_Process_Options &options);virtual pid_t spawn (ACE_Process_Options &options);virtual void parent (pid_t child);virtual void child (pid_t parent);virtual void unmanage (void);pid_t wait (ACE_exitcode *status = 0, int wait_options = 0);pid_t wait (const ACE_Time_Value &tv, ACE_exitcode *status = 0);int kill (int signum = SIGINT);int terminate (void);pid_t getpid (void) const;ACE_HANDLE gethandle (void) const;int running (void) const;int exit_code (void) const;void exit_code (int code);PROCESS_INFORMATION process_info (void);protected:PROCESS_INFORMATION process_info_;pid_t child_id_;int exit_code_;};
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.
ACE_Process (void);
ACE_Process::spawn to start.
virtual ~ACE_Process (void);
virtual int prepare (ACE_Process_Options &options);
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.
virtual pid_t spawn (ACE_Process_Options &options);
options. Returns the
process id of the newly spawned child on success or -1 on
failure.
virtual void parent (pid_t child);
ACE_OS::fork in the parent's context, if the
fork succeeds. The default is to do nothing.
virtual void child (pid_t parent);
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.
virtual void unmanage (void);
Process_Manager that is removing this Process from
its table of managed Processes. Default is to do nothing.
pid_t wait (ACE_exitcode *status = 0, int wait_options = 0);
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.
pid_t wait (const ACE_Time_Value &tv, ACE_exitcode *status = 0);
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
SIGCHLDs during the timeout period, which will break another
ACE_Process_Manager in the same process that's expecting
SIGCHLD to kick off process reaping.
int kill (int signum = SIGINT);
int terminate (void);
ACE::terminate_process.
This call doesn't give the process a chance to cleanup, so use it
with caution...
pid_t getpid (void) const;
ACE_HANDLE gethandle (void) const;
int running (void) const;
int exit_code (void) const;
void exit_code (int code);
PROCESS_INFORMATION process_info (void);
PROCESS_INFORMATION process_info_;
pid_t child_id_;
int exit_code_;
harrison@cs.wustl.edu