[PATCH i-g-t 1/3] lib/eudebug: Make debugger thread SIGINTable
Mika Kuoppala
mika.kuoppala at linux.intel.com
Mon Mar 10 11:40:21 UTC 2025
Dominik Karol Piątkowski <dominik.karol.piatkowski at intel.com> writes:
> 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;
We should be safe to assume sigaction initializes everything
that it will use. Regarless sa = { 0 }; would help to convince
the reader that everything will be allright.
Regarless,
Reviewed-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>
>
> 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