mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-04 22:09:57 +02:00
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>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user