53 virtual int getId() = 0;
56 virtual void kill() = 0;
59 virtual bool done() = 0;
62 virtual void finished(
int exit_status ) = 0;
76 std::vector< std::string> params;
82 int exitSignal, exitStatus;
95 ChildProcess(
const std::string &cmnd,
int *fdin =
nullptr,
int *fdout =
nullptr );
107 virtual void setArgs(
const std::vector< std::string> &args );
116 virtual int signal(
int sig );
124 virtual void finished(
int result );
130 virtual int getId() {
return (
int)pid; }
173 void installSignalHandler();
176 static void childDiedSignalHandler(
int sig );
177 static void childDiedSignalAction(
int sig, siginfo_t *,
void *);
180 std::map< pid_t, AbstractChildProcess * > children;
183 void (*otherHandler)(int);
184 void (*otherAction)(int, siginfo_t *,
void *);
187 std::vector< ProcessOwner * > owners;
188 mutable std::mutex accessMx;
int getExitSignal()
get the signal that caused the process to exit.
Definition: proc.h:133
bool done()
get the running status of the program
Definition: proc.h:127
virtual ~ProcessOwner()
Destructor.
Definition: proc.h:147
virtual void kill()=0
Terminates the child process.
virtual bool done()=0
get the running state of the process.
int numberOfLiveChildren() const
get the number of running children
Definition: proc.cpp:349
int numberOfChildren() const
get the number of child processes
Definition: proc.h:216
void registerChild(AbstractChildProcess *cp)
tell the manager about a child
Definition: proc.cpp:307
virtual int getId()=0
Returns the pid of the child process.
static ChildProcessMgr & instance()
get reference to the child process manager
Definition: proc.cpp:280
virtual ~AbstractChildProcess()
Destructor.
Definition: proc.h:50
virtual void kill()
terminate the process
Definition: proc.cpp:82
virtual int signal(int sig)
send a signal to the process
Definition: proc.cpp:98
ChildProcess()
constructor for fork
Definition: proc.cpp:49
void registerOwner(ProcessOwner *)
register an object that is to be notified of a child's death
Definition: proc.cpp:298
Manage the child processes.
Definition: proc.h:166
virtual void finished(int exit_status)=0
Called by the manager when the child completes.
void shutDown()
terminate all the child processes
Definition: proc.cpp:325
virtual ~ChildProcess()
destructor
Definition: proc.cpp:57
virtual void setArgs(const std::vector< std::string > &args)
set the args for the process
Definition: proc.cpp:68
virtual void processTerminated(AbstractChildProcess *cp)=0
Notification that process terminated.
Abstract child process interface for ChildProcessMgr.
Definition: proc.h:46
virtual void finished(int result)
set the exit status of the process
Definition: proc.cpp:109
virtual int getId()
get the process id
Definition: proc.h:130
Represents the state of a child process.
Definition: proc.h:71
void deregisterChild(AbstractChildProcess *cp)
forget about a child
Definition: proc.cpp:316
virtual void run()
start the command running
Definition: proc.cpp:75
Interface that allows the owner of a child process to be notified.
Definition: proc.h:143