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>
pull/416/head
Yasushi SHOJI 2023-03-20 10:04:56 +09:00
parent 4ec42fa089
commit 74e0d28d1a
1 changed files with 5 additions and 0 deletions

View File

@ -91,6 +91,7 @@
extern int optind, opterr, optopt; extern int optind, opterr, optopt;
static volatile int running = 1; static volatile int running = 1;
static volatile sig_atomic_t signal_num;
static unsigned long long enobufs_count; static unsigned long long enobufs_count;
static bool ignore_enobufs; static bool ignore_enobufs;
static bool use_so_txtime; static bool use_so_txtime;
@ -220,6 +221,7 @@ static void print_usage(char *prg)
static void sigterm(int signo) static void sigterm(int signo)
{ {
running = 0; running = 0;
signal_num = signo;
} }
static int setsockopt_txtime(int fd) static int setsockopt_txtime(int fd)
@ -887,5 +889,8 @@ int main(int argc, char **argv)
close(s); close(s);
if (signal_num)
return 128 + signal_num;
return 0; return 0;
} }