From: Bartosz Golaszewski Date: Mon, 12 Jun 2017 20:25:09 +0000 (+0200) Subject: tests: read siginfo after receiving SIGCHLD X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f48aa23289e03196907011af6622d7d97a24dbd6;p=qemu-gpiodev%2Flibgpiod.git tests: read siginfo after receiving SIGCHLD 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 --- diff --git a/tests/gpiod-test.c b/tests/gpiod-test.c index 6a671e6..eb3fbff 100644 --- a/tests/gpiod-test.c +++ b/tests/gpiod-test.c @@ -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);