mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 06:41:42 +08:00
Add a fish_test_helper command to print blocked signals
This commit is contained in:
parent
385b069eb2
commit
866d506d11
|
@ -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"},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user