[PATCH i-g-t 1/3] lib/eudebug: Make debugger thread SIGINTable

Dominik Karol Piątkowski dominik.karol.piatkowski at intel.com
Mon Feb 24 13:08:05 UTC 2025


Due to the fact that `pthread_kill(thread, SIGINT)` results in SIGINTing
all of the threads - including main thread - by default, testcases that
send SIGINT to debugger thread are crashing.

Introduce SIGINT signal handler for debugger thread to fix this.

Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski at intel.com>
---
 lib/xe/xe_eudebug.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/xe/xe_eudebug.c b/lib/xe/xe_eudebug.c
index 1205d945b..ad8bdf68a 100644
--- a/lib/xe/xe_eudebug.c
+++ b/lib/xe/xe_eudebug.c
@@ -1050,6 +1050,11 @@ xe_eudebug_read_event(int fd, struct drm_xe_eudebug_event *event)
 	return ret;
 }
 
+static void terminate_debugger(int sig)
+{
+	pthread_exit(NULL);
+}
+
 static void *debugger_worker_loop(void *data)
 {
 	uint8_t buf[MAX_EVENT_SIZE];
@@ -1060,9 +1065,14 @@ static void *debugger_worker_loop(void *data)
 		.revents = 0,
 	};
 	int timeout_ms = 100, ret;
+	struct sigaction sa;
 
 	igt_assert(d->master_fd >= 0);
 
+	igt_assert_eq(sigaction(SIGINT, NULL, &sa), 0);
+	sa.sa_handler = terminate_debugger;
+	igt_assert_eq(sigaction(SIGINT, &sa, NULL), 0);
+
 	do {
 		p.fd = d->fd;
 		ret = poll(&p, 1, timeout_ms);
-- 
2.34.1



More information about the igt-dev mailing list