From 34098b71fa1b365ffb0c12fb84ebb7aa26c8f300 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 17 Mar 2016 09:53:45 +0000 Subject: [PATCH] lib/igt_gt: Handle SIGINT whilst writing to i915_error_state Becareful in case we try and eat the error state whilst interrupts are being sent and repeat the write() until we finish uninterrupted. References: https://bugs.freedesktop.org/show_bug.cgi?id=94573 Signed-off-by: Chris Wilson --- lib/igt_gt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/igt_gt.c b/lib/igt_gt.c index c7e16e35..d2ae0587 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -225,10 +225,14 @@ igt_hang_ring_t igt_hang_ring(int fd, int ring) static void eat_error_state(void) { - int fd; + int fd, ret; fd = igt_debugfs_open("i915_error_state", O_WRONLY); - igt_assert(write(fd, "", 1) == 1); + do { + ret = write(fd, "", 1); + if (ret < 0) + ret = -errno; + } while (ret == -EINTR || ret == -EAGAIN); close(fd); }