Add a fish_test_helper command to print blocked signals

This commit is contained in:
ridiculousfish 2020-04-05 15:07:42 -07:00
parent 385b069eb2
commit 866d506d11

View File

@ -69,6 +69,23 @@ static void print_fds() {
fputc('\n', stdout);
}
static void print_blocked_signals() {
sigset_t sigs;
sigemptyset(&sigs);
if (sigprocmask(SIG_SETMASK, nullptr, &sigs)) {
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++) {
if (sigismember(&sigs, sig)) {
if (const char *s = strsignal(sig)) {
fprintf(stderr, "%s\n", s);
}
}
}
}
static void show_help();
/// A thing that fish_test_helper can do.
@ -93,6 +110,7 @@ static fth_command_t s_commands[] = {
{"print_pid_then_sleep", print_pid_then_sleep, "Print our pid, then sleep for .5 seconds"},
{"print_pgrp", print_pgrp, "Print our pgroup to stdout"},
{"print_fds", print_fds, "Print the list of active FDs to stdout"},
{"print_blocked_signals", print_blocked_signals, "Print to stdout the name(s) of blocked signals"},
{"help", show_help, "Print list of fish_test_helper commands"},
};