diff options
-rw-r--r-- | include/TaskMan.h | 3 | ||||
-rw-r--r-- | lib/TaskMan.cc | 19 |
2 files changed, 20 insertions, 2 deletions
diff --git a/include/TaskMan.h b/include/TaskMan.h index 48887c4..db9a949 100644 --- a/include/TaskMan.h +++ b/include/TaskMan.h @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: TaskMan.h,v 1.25 2007-05-30 11:57:08 pixel Exp $ */ +/* $Id: TaskMan.h,v 1.26 2007-12-20 17:07:11 pixel Exp $ */ #ifndef __TASKMAN_H__ #define __TASKMAN_H__ @@ -42,6 +42,7 @@ class TaskMan : public Base { static void WaitFor(pid_t, Task *, int = 0); static void WaitFor(const timeval &, Task *, int = 0); static int GotChild(pid_t, int); + static void CleanChildren(); static void Stop(); static int Event(); static Task * Etask(); diff --git a/lib/TaskMan.cc b/lib/TaskMan.cc index 5064048..24bbf77 100644 --- a/lib/TaskMan.cc +++ b/lib/TaskMan.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: TaskMan.cc,v 1.47 2007-06-25 10:11:28 pixel Exp $ */ +/* $Id: TaskMan.cc,v 1.48 2007-12-20 17:07:11 pixel Exp $ */ #ifndef _WIN32 #include <signal.h> @@ -67,6 +67,22 @@ void taskman_sighup(int sig) { } #endif +void TaskMan::CleanChildren() { +#ifndef _WIN32 + int status; + pid_t pid; + + while (1) { + pid = waitpid(-1, &status, WNOHANG); + if (GotChild(pid, status)) { + got_sigchild++; + } else { + WaitFor(pid, 0, status); + } + } +#endif +} + void TaskMan::SigChild() { int status; pid_t pid; @@ -624,6 +640,7 @@ void TaskMan::MainLoop() throw (GeneralException) { #ifndef _WIN32 sigprocmask(SIG_BLOCK, &sigchildset, 0); #endif + CleanChildren(); if (r < 0) { if (errno != EINTR) { throw GeneralException(String(_("Error during poll: ")) + strerror(errno)); |