mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-04 22:09:57 +02:00
cangen: 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:
@@ -91,6 +91,7 @@
|
||||
extern int optind, opterr, optopt;
|
||||
|
||||
static volatile int running = 1;
|
||||
static volatile sig_atomic_t signal_num;
|
||||
static unsigned long long enobufs_count;
|
||||
static bool ignore_enobufs;
|
||||
static bool use_so_txtime;
|
||||
@@ -220,6 +221,7 @@ static void print_usage(char *prg)
|
||||
static void sigterm(int signo)
|
||||
{
|
||||
running = 0;
|
||||
signal_num = signo;
|
||||
}
|
||||
|
||||
static int setsockopt_txtime(int fd)
|
||||
@@ -887,5 +889,8 @@ int main(int argc, char **argv)
|
||||
|
||||
close(s);
|
||||
|
||||
if (signal_num)
|
||||
return 128 + signal_num;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user