summaryrefslogtreecommitdiff
path: root/lib/TaskMan.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/TaskMan.cc')
-rw-r--r--lib/TaskMan.cc27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/TaskMan.cc b/lib/TaskMan.cc
index 48cead4..1752d8d 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.55 2008-02-18 10:00:21 pixel Exp $ */
+/* $Id: TaskMan.cc,v 1.56 2008-07-02 10:05:16 pixel Exp $ */
#ifndef _WIN32
#include <signal.h>
@@ -92,6 +92,7 @@ void TaskMan::CleanChildren() {
}
void TaskMan::SigChild() {
+#if 0
int status;
pid_t pid;
@@ -101,7 +102,7 @@ void TaskMan::SigChild() {
} else {
WaitFor(pid, 0, status);
}
-
+#endif
// cerr << "Got SIGCHILD, pid = " << pid << " and status = " << status << endl;
}
@@ -324,9 +325,14 @@ void TaskMan::Init() throw (GeneralException) {
signal(SIGHUP, taskman_sighup);
signal(SIGUSR1, taskman_sigusr1);
+ sigset_t sigtempset;
+
sigemptyset(&sigchildset);
- sigaddset(&sigchildset, SIGCHLD);
- sigprocmask(SIG_BLOCK, &sigchildset, 0);
+ sigemptyset(&sigtempset);
+ sigprocmask(SIG_SETMASK, 0, &sigchildset);
+ sigprocmask(SIG_SETMASK, 0, &sigtempset);
+ sigaddset(&sigtempset, SIGCHLD);
+ sigprocmask(SIG_SETMASK, &sigtempset, 0);
#endif
inited = true;
@@ -676,11 +682,14 @@ void TaskMan::MainLoop() throw (GeneralException) {
bool timeout_condition = no_burst && !Zombies.size() && !got_sigchild && !got_yield;
#ifdef _WIN32
- r = poll(ufsd, nfds, timeout_condition ? timeout: 0);
+ r = poll(ufsd, nfds, timeout_condition ? timeout : 0);
#else
- sigprocmask(SIG_UNBLOCK, &sigchildset, 0);
- r = poll(ufsd, nfds, timeout_condition ? timeout: 0);
- sigprocmask(SIG_BLOCK, &sigchildset, 0);
+ struct timespec ttimeout = { 0, 0 };
+ if (timeout != -1) {
+ ttimeout.tv_sec = timeout / 1000;
+ ttimeout.tv_nsec = (timeout - (ttimeout.tv_sec * 1000)) * 1000000;
+ }
+ r = ppoll(ufsd, nfds, (timeout != -1) || !timeout_condition ? &ttimeout : 0, &sigchildset);
#endif
CleanChildren();
if (r < 0) {
@@ -780,6 +789,8 @@ void TaskMan::MainLoop() throw (GeneralException) {
for (std::vector<w4pr_t>::iterator p = w4pr.begin(); p != w4pr.end(); p++) {
if (p->flag) {
Task * t;
+ if (!p->T)
+ continue;
if (p->T->IsStopped()) {
continue;
}