cansniffer: 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
parent
3caf692925
commit
3ef3d72738
|
|
@ -124,6 +124,7 @@ extern int optind, opterr, optopt;
|
||||||
|
|
||||||
static int idx;
|
static int idx;
|
||||||
static int running = 1;
|
static int running = 1;
|
||||||
|
static volatile sig_atomic_t signal_num;
|
||||||
static int clearscreen = 1;
|
static int clearscreen = 1;
|
||||||
static int print_eff;
|
static int print_eff;
|
||||||
static int print_ascii = 1;
|
static int print_ascii = 1;
|
||||||
|
|
@ -243,6 +244,7 @@ void print_usage(char *prg)
|
||||||
void sigterm(int signo)
|
void sigterm(int signo)
|
||||||
{
|
{
|
||||||
running = 0;
|
running = 0;
|
||||||
|
signal_num = signo;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
|
@ -428,6 +430,10 @@ int main(int argc, char **argv)
|
||||||
printf("%s", CSR_SHOW); /* show cursor */
|
printf("%s", CSR_SHOW); /* show cursor */
|
||||||
|
|
||||||
close(s);
|
close(s);
|
||||||
|
|
||||||
|
if (signal_num)
|
||||||
|
return 128 + signal_num;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue