--- projects/pjob/pjob.c 2006/01/23 22:12:39 1.2 +++ projects/pjob/pjob.c 2006/01/24 20:15:25 1.3 @@ -85,6 +85,9 @@ void process_child(gpointer data, gpointer user_data){ struct pollfd fds[3]; gint fdssize=2; + proc->timer = g_timer_new(); + g_timer_start(proc->timer); + /* Setup files in output dir if requested to do so */ if(outdir != NULL){ proc->file_stdout = g_strdup_printf("%s/%s-STDOUT", outdir, proc->jobname); @@ -162,7 +165,7 @@ void process_child(gpointer data, gpointer user_data){ poll(fds, fdssize, -1); /* For stdout and stderr see if there is any data, and read it */ for(x=0; x<2; x++){ - if((fds[x].revents|POLLIN) == fds[x].revents){ + if((fds[x].revents & POLLIN) == 0){ /* We have data to read */ g_io_channel_read_line(sout[x], &readbuf, &rdatasize, NULL, NULL); if(rdatasize > 0){ @@ -180,7 +183,7 @@ void process_child(gpointer data, gpointer user_data){ } } /* See if we need to pump more data down stdin */ - if((fds[2].revents|POLLOUT) == fds[2].revents){ + if((fds[2].revents & POLLOUT) != 0){ /* We have data we can write */ gchar *nextline; gint nextlinesize; @@ -202,8 +205,10 @@ void process_child(gpointer data, gpointer user_data){ /* Even if we did get a hangup - lets make sure there is no more data to read first by looping again */ if (readdata) continue; - if(((fds[0].revents|POLLHUP) == fds[0].revents) && ((fds[1].revents|POLLHUP) == fds[1].revents)) break; + if(((fds[0].revents & POLLHUP) != 0) && ((fds[1].revents & POLLHUP) != 0)) break; } + + g_timer_stop(proc->timer); g_io_channel_shutdown(sout[0], TRUE, NULL); g_io_channel_shutdown(sout[1], TRUE, NULL);