Mercurial > dropbear
diff svr-main.c @ 893:860e3522f8fc
- Save errno in signal handlers
- Use _exit() in segv handler
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 15 Feb 2014 21:13:57 +0800 |
parents | aa689d140928 |
children | 0bb16232e7c4 |
line wrap: on
line diff
--- a/svr-main.c Fri Feb 14 23:18:45 2014 +0800 +++ b/svr-main.c Sat Feb 15 21:13:57 2014 +0800 @@ -337,6 +337,8 @@ 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 @@ 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 */