isotptun: 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
3ef3d72738
commit
180eceff4d
|
|
@ -79,6 +79,7 @@
|
|||
#define BUF_LEN (MAX_PDU_LENGTH + 1)
|
||||
|
||||
static volatile int running = 1;
|
||||
static volatile sig_atomic_t signal_num;
|
||||
|
||||
static void fake_syslog(int priority, const char *format, ...)
|
||||
{
|
||||
|
|
@ -130,6 +131,7 @@ void print_usage(char *prg)
|
|||
void sigterm(int signo)
|
||||
{
|
||||
running = 0;
|
||||
signal_num = signo;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
@ -403,5 +405,9 @@ int main(int argc, char **argv)
|
|||
|
||||
close(s);
|
||||
close(t);
|
||||
|
||||
if (signal_num)
|
||||
return 128 + signal_num;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue