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.
This commit is contained in:
Johannes Altmanninger 2020-04-07 21:22:14 +02:00
parent c1b2b6b7da
commit 90f67e4009

View File

@ -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");
}
}
}