tests: read siginfo after receiving SIGCHLD
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 12 Jun 2017 20:25:09 +0000 (22:25 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 12 Jun 2017 20:25:09 +0000 (22:25 +0200)
If we don't actually read the signal info, the signals pile up after
every child process exits even if we close the sigfd.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
tests/gpiod-test.c

index 6a671e6aa40bec31a61d7b14463ac679af0149fa..eb3fbff6c604c23f5f76f174dc28fa3f65b9c7f2 100644 (file)
@@ -551,9 +551,11 @@ static void gpiotool_readall(int fd, char **out)
 
 void test_tool_wait(void)
 {
+       struct signalfd_siginfo sinfo;
        struct gpiotool_proc *proc;
        struct pollfd pfd;
        int status;
+       ssize_t rd;
 
        proc = &globals.test_ctx.tool_proc;
 
@@ -577,7 +579,12 @@ void test_tool_wait(void)
                die_perr("error when polling the signalfd");
        }
 
+       rd = read(proc->sig_fd, &sinfo, sizeof(sinfo));
        close(proc->sig_fd);
+       if (rd < 0)
+               die_perr("error reading signal info");
+       else if (rd != sizeof(sinfo))
+               die("invalid size of signal info");
 
        gpiotool_readall(proc->stdout_fd, &proc->stdout);
        gpiotool_readall(proc->stderr_fd, &proc->stderr);