From 90f67e4009e3c53e9d1c3cc6303617ca930acf91 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 7 Apr 2020 21:22:14 +0200 Subject: [PATCH] fish_test_helper: print only blocked 64 blocked signals Otherwise it would print "Unknown Signal" on Linux. I didn't see an obvious way to check signal validity, plus it hardly matters. Also mimic the output from BSD strsignal on Linux. --- src/fish_test_helper.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fish_test_helper.cpp b/src/fish_test_helper.cpp index d530ec3e6..afb0b94ed 100644 --- a/src/fish_test_helper.cpp +++ b/src/fish_test_helper.cpp @@ -76,11 +76,16 @@ static void print_blocked_signals() { perror("sigprocmask"); exit(EXIT_FAILURE); } - // There is no obviously portable way to get the maximum number of signals; here we limit it to 128. - for (int sig=1; sig < 128; sig++) { + // There is no obviously portable way to get the maximum number of signals. + // Here we limit it to 64 because strsignal on Linux returns "Unknown signal" for anything above. + for (int sig=1; sig < 65; sig++) { if (sigismember(&sigs, sig)) { if (const char *s = strsignal(sig)) { - fprintf(stderr, "%s\n", s); + fprintf(stderr, "%s", s); + if (strchr(s, ':') == nullptr) { + fprintf(stderr, ": %d", sig); + } + fprintf(stderr, "\n"); } } }