54 virtual int getId() = 0;
57 virtual void kill() = 0;
60 virtual bool done() = 0;
63 virtual void finished(
int exit_status ) = 0;
77 std::vector< std::string> params;
84 int exitSignal, exitStatus;
99 ChildProcess(
const std::string &cmnd,
int *fdin =
nullptr,
int *fdout =
nullptr,
int *fderr =
nullptr );
111 virtual void setArgs(
const std::vector< std::string> &args );
120 virtual int signal(
int sig );
128 virtual void finished(
int result );
134 virtual int getId() {
return (
int)pid; }
180 std::unique_ptr<std::thread> thread;
200 void installSignalHandler();
203 static void childDiedSignalHandler(
int sig );
204 static void childDiedSignalAction(
int sig, siginfo_t *,
void *);
207 std::map< pid_t, AbstractChildProcess * > children;
210 void (*otherHandler)(int);
211 void (*otherAction)(int, siginfo_t *,
void *);
214 std::vector< ProcessOwner * > owners;
215 mutable std::mutex accessMx;
virtual int getId()=0
Returns the pid of the child process.
void shutDown()
terminate all the child processes
Definition: proc.cpp:406
Interface that allows the owner of a child process to be notified.
Definition: proc.h:153
void registerOwner(ProcessOwner *)
register an object that is to be notified of a child's death
Definition: proc.cpp:379
static ChildProcessMgr & instance()
get reference to the child process manager
Definition: proc.cpp:296
virtual void run()
start the command running
Definition: proc.cpp:75
virtual void setArgs(const std::vector< std::string > &args)
set the args for the process
Definition: proc.cpp:68
virtual void finished(int result)
set the exit status of the process
Definition: proc.cpp:109
int getExitSignal()
get the signal that caused the process to exit.
Definition: proc.h:137
virtual ~ChildProcess()
destructor
Definition: proc.cpp:57
int getExitStatus()
get the exit status
Definition: proc.h:140
int numberOfChildren() const
get the number of child processes
Definition: proc.h:246
virtual void kill()
terminate the process
Definition: proc.cpp:82
Abstract child process interface for ChildProcessMgr.
Definition: proc.h:47
virtual int signal(int sig)
send a signal to the process
Definition: proc.cpp:98
ChildProcess()
constructor for fork
Definition: proc.cpp:49
void deregisterChild(AbstractChildProcess *cp)
forget about a child
Definition: proc.cpp:397
void reportExitErrors(bool x)
turn on or off the reporting of error exits
Definition: proc.h:143
virtual void processTerminated(AbstractChildProcess *cp)=0
Notification that process terminated.
virtual ~AbstractChildProcess()
Destructor.
Definition: proc.h:51
virtual int getId()
get the process id
Definition: proc.h:134
virtual ~ProcessOwner()
Destructor.
Definition: proc.h:157
virtual void kill()=0
Terminates the child process.
virtual void finished(int exit_status)=0
Called by the manager when the child completes.
int numberOfLiveChildren() const
get the number of running children
Definition: proc.cpp:430
void registerChild(AbstractChildProcess *cp)
tell the manager about a child
Definition: proc.cpp:388
virtual bool done()=0
get the running state of the process.
bool done()
get the running status of the program
Definition: proc.h:131
Manage the child processes.
Definition: proc.h:176
Represents the state of a child process.
Definition: proc.h:72