diff --git a/src/fish_test_helper.cpp b/src/fish_test_helper.cpp index bb56debfa..d530ec3e6 100644 --- a/src/fish_test_helper.cpp +++ b/src/fish_test_helper.cpp @@ -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"}, };