From d320877b07d14b479eb45f6ebba80105d888231e Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 26 May 2026 19:57:14 +1000 Subject: [PATCH] tests: More portable installation of SIGINT handler Our tests install SIGINT handlers using sigaction(), but that isn't available on Windows / mingw, blocking use of the tests there. Use the more portable signal() instead - it's good enough for our needs. Avoid strsignal() for the same reason. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: David Gibson --- AGENTS.md | 1 + tests/testutils.c | 17 +++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 82d5996..2f0264f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -86,6 +86,7 @@ See the "AI Coding Assistants" section in CONTRIBUTING.md. Key rules: - **Do not** add `Signed-off-by` tags — only humans can certify the DCO - Use `Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]` for attribution in commit messages - The human submitter is responsible for reviewing all AI-generated code and ensuring license compliance +- Do not add `Co-authored-by` tags. ## Tagging a New Release diff --git a/tests/testutils.c b/tests/testutils.c index 5ab4324..6d69e87 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -42,24 +42,21 @@ static inline void VALGRIND_MAKE_MEM_DEFINED(void *p, size_t len) int verbose_test = 1; char *test_name; -static void sigint_handler(int signum, siginfo_t *si, void *uc) +static void sigint_handler(int signum) { - fprintf(stderr, "%s: %s (pid=%d)\n", test_name, - strsignal(signum), getpid()); + fprintf(stderr, "%s: signal %d (pid=%d)\n", test_name, + signum, getpid()); exit(RC_BUG); } void test_init(int argc, char *argv[]) { - int err; - struct sigaction sa_int = { - .sa_sigaction = sigint_handler, - }; - test_name = argv[0]; - err = sigaction(SIGINT, &sa_int, NULL); - if (err) + /* Use signal(), not sigaction() because it also works on the Windows / + * mingw environments we support. + */ + if (signal(SIGINT, sigint_handler) == SIG_ERR) FAIL("Can't install SIGINT handler"); if (getenv("QUIET_TEST"))