cansequence: Follow Bash exit status when signaled

Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
pull/416/head
Yasushi SHOJI 2023-03-20 10:05:19 +09:00
parent 74e0d28d1a
commit 3caf692925
1 changed files with 5 additions and 0 deletions

View File

@ -33,6 +33,7 @@ extern int optind, opterr, optopt;
static int s = -1;
static bool running = true;
static volatile sig_atomic_t signal_num;
static bool infinite = true;
static unsigned int drop_until_quit;
static unsigned int drop_count;
@ -73,6 +74,7 @@ static void print_usage(char *prg)
static void sig_handler(int signo)
{
running = false;
signal_num = signo;
}
@ -367,5 +369,8 @@ int main(int argc, char **argv)
else
do_send();
if (signal_num)
return 128 + signal_num;
exit(EXIT_SUCCESS);
}