From 072bbf12707afa65cbe9c7d7ce81eb8ef5bd1d5b Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 7 Mar 2017 15:13:47 +0000 Subject: lib: Break poll loop to check for a missed signal If our parent dies, so should we. Our parent should kill us before it exits, but just in case we escape, wake up periodically to check upon our parent. Signed-off-by: Chris Wilson --- lib/igt_aux.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/igt_aux.c') diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 447e4f08..2eb71449 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -359,6 +359,7 @@ hang_detector_process(pid_t pid, dev_t rdev) struct udev_monitor *mon = udev_monitor_new_from_netlink(udev_new(), "kernel"); struct pollfd pfd; + int ret; udev_monitor_filter_add_match_subsystem_devtype(mon, "drm", NULL); udev_monitor_enable_receiving(mon); @@ -366,14 +367,19 @@ hang_detector_process(pid_t pid, dev_t rdev) pfd.fd = udev_monitor_get_fd(mon); pfd.events = POLLIN; - while (poll(&pfd, 1, -1) > 0) { + while ((ret = poll(&pfd, 1, 2000)) >= 0) { struct udev_device *dev; dev_t devnum; - if (kill(pid, 0)) /* Parent has died, so must we. */ + if (kill(pid, 0)) { /* Parent has died, so must we. */ + igt_warn("Parent died without killing its children (%s)\n", + __func__); break; + } - dev = udev_monitor_receive_device(mon); + dev = NULL; + if (ret > 0) + dev = udev_monitor_receive_device(mon); if (dev == NULL) continue; -- cgit v1.2.3