From 9cf56047fbbb44328e2a30d3f9ec17b4b107fc24 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Fri, 16 Sep 2022 18:53:05 -0500 Subject: [PATCH] Prevent anyone else from wasting time w/ sigqueue(2) It turns out there *is* an obviously portable way... except it's not-so-obviously not portable after all. POSIX specifies that sigqueue(2) can be used to validate pid and signo separately, returning EINVAL in the specific case of an invalid or unsupported signal number. This would be perfect... if only it were actually implemented. --- src/fish_test_helper.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fish_test_helper.cpp b/src/fish_test_helper.cpp index cac2838d8..475c56ddc 100644 --- a/src/fish_test_helper.cpp +++ b/src/fish_test_helper.cpp @@ -135,9 +135,10 @@ static void print_blocked_signals() { exit(EXIT_FAILURE); } // There is no obviously portable way to get the maximum number of signals. + // POSIX says sigqueue(2) can be used with signo 0 to validate the pid and signo parameters, + // but it is missing from OpenBSD and returns ENOSYS (not implemented) under WSL. // Here we limit it to 32 because strsignal on OpenBSD returns "Unknown signal" for anything - // above. - // NetBSD taps out at 63, Linux at 64. + // above, while NetBSD taps out at 63, and Linux at 64. for (int sig = 1; sig < 33; sig++) { if (sigismember(&sigs, sig)) { print_signal(sig);