mirror of
https://github.com/clearml/dropbear
synced 2025-03-03 10:41:39 +00:00
- Save errno in signal handlers
- Use _exit() in segv handler
This commit is contained in:
parent
73444f2957
commit
1dc5312f00
@ -87,6 +87,8 @@ static void sesssigchild_handler(int UNUSED(dummy)) {
|
|||||||
struct sigaction sa_chld;
|
struct sigaction sa_chld;
|
||||||
struct exitinfo *exit = NULL;
|
struct exitinfo *exit = NULL;
|
||||||
|
|
||||||
|
const int saved_errno = errno;
|
||||||
|
|
||||||
TRACE(("enter sigchld handler"))
|
TRACE(("enter sigchld handler"))
|
||||||
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
|
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
|
||||||
TRACE(("sigchld handler: pid %d", pid))
|
TRACE(("sigchld handler: pid %d", pid))
|
||||||
@ -140,6 +142,8 @@ static void sesssigchild_handler(int UNUSED(dummy)) {
|
|||||||
sigemptyset(&sa_chld.sa_mask);
|
sigemptyset(&sa_chld.sa_mask);
|
||||||
sigaction(SIGCHLD, &sa_chld, NULL);
|
sigaction(SIGCHLD, &sa_chld, NULL);
|
||||||
TRACE(("leave sigchld handler"))
|
TRACE(("leave sigchld handler"))
|
||||||
|
|
||||||
|
errno = saved_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send the exit status or the signal causing termination for a session */
|
/* send the exit status or the signal causing termination for a session */
|
||||||
|
@ -337,6 +337,8 @@ out:
|
|||||||
static void sigchld_handler(int UNUSED(unused)) {
|
static void sigchld_handler(int UNUSED(unused)) {
|
||||||
struct sigaction sa_chld;
|
struct sigaction sa_chld;
|
||||||
|
|
||||||
|
const int saved_errno = errno;
|
||||||
|
|
||||||
while(waitpid(-1, NULL, WNOHANG) > 0);
|
while(waitpid(-1, NULL, WNOHANG) > 0);
|
||||||
|
|
||||||
sa_chld.sa_handler = sigchld_handler;
|
sa_chld.sa_handler = sigchld_handler;
|
||||||
@ -344,13 +346,14 @@ static void sigchld_handler(int UNUSED(unused)) {
|
|||||||
if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) {
|
if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) {
|
||||||
dropbear_exit("signal() error");
|
dropbear_exit("signal() error");
|
||||||
}
|
}
|
||||||
|
errno = saved_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* catch any segvs */
|
/* catch any segvs */
|
||||||
static void sigsegv_handler(int UNUSED(unused)) {
|
static void sigsegv_handler(int UNUSED(unused)) {
|
||||||
fprintf(stderr, "Aiee, segfault! You should probably report "
|
fprintf(stderr, "Aiee, segfault! You should probably report "
|
||||||
"this as a bug to the developer\n");
|
"this as a bug to the developer\n");
|
||||||
exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* catch ctrl-c or sigterm */
|
/* catch ctrl-c or sigterm */
|
||||||
|
Loading…
Reference in New Issue
Block a user