]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed bug in handling POLLHUP for stdin
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 31 Oct 2019 19:29:12 +0000 (15:29 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 31 Oct 2019 19:29:12 +0000 (15:29 -0400)
src/lib/job.c

index 1ec1f6445e5fe2eb66243b2773418e5c4680ef20..2c0bbbfe6254bb7ad34c5741b26f4d44ea9c1793 100644 (file)
@@ -27,6 +27,7 @@ static void pipe_read(Job* job)
     char buffer[32769];
     errno = 0;
     long nread = read(job->fd, buffer, sizeof(buffer)-1);
+    telem_send("PIPE_READ(fd : %d, ret: %ld)\n", job->fd, nread);
     if (nread <= 0)
     {
         job->readfn = NULL;
@@ -94,7 +95,7 @@ static void job_process(int fd, int events)
         job = job->next;
     if (!job || !events) return;
     telem_send("JOB(fd: %d, events: 0x%x)\n", fd, events);
-    if (job->readfn && (events & POLLIN))
+    if (job->readfn && (events & (POLLIN|POLLHUP)))
     {
         telem_send("JOB_READ(fd: %d)\n", job->fd);
         job->readfn(job);
@@ -104,7 +105,7 @@ static void job_process(int fd, int events)
         telem_send("JOB_WRITE(fd: %d)\n", job->fd);
         job->writefn(job);
     }
-    if ((events & (POLLHUP|POLLERR) && !job->readfn) || (!job->readfn && !job->writefn))
+    if ((events & POLLERR) || (!job->readfn && !job->writefn))
     {
         telem_send("JOB_FINISH(fd: %d)\n", job->fd);
         job_finish(job);