diff options
author | Matt Johnston <matt@ucc.asn.au> | 2014-02-15 21:13:57 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2014-02-15 21:13:57 +0800 |
commit | 1dc5312f00c80e2f0b06838b671bf32d63936f41 (patch) | |
tree | a7c7262ca0e1d1c72646ffafb2280b2019b2d00c /svr-main.c | |
parent | 73444f2957f15e808d1c5d0547a1b4993dc2f160 (diff) |
- Save errno in signal handlers
- Use _exit() in segv handler
Diffstat (limited to 'svr-main.c')
-rw-r--r-- | svr-main.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -337,6 +337,8 @@ out: static void sigchld_handler(int UNUSED(unused)) { struct sigaction sa_chld; + const int saved_errno = errno; + while(waitpid(-1, NULL, WNOHANG) > 0); sa_chld.sa_handler = sigchld_handler; @@ -344,13 +346,14 @@ static void sigchld_handler(int UNUSED(unused)) { if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) { dropbear_exit("signal() error"); } + errno = saved_errno; } /* catch any segvs */ static void sigsegv_handler(int UNUSED(unused)) { fprintf(stderr, "Aiee, segfault! You should probably report " "this as a bug to the developer\n"); - exit(EXIT_FAILURE); + _exit(EXIT_FAILURE); } /* catch ctrl-c or sigterm */ |