1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

Unify tmate-debug.c with tmate

This commit is contained in:
Nicolas Viennot 2019-11-10 14:05:34 -05:00
parent f132989294
commit ecc15f6022
2 changed files with 9 additions and 15 deletions

View File

@ -85,15 +85,16 @@ void tmate_print_stack_trace(void)
free (strings);
}
static void handle_crash(__unused int sig)
static void handle_crash(int sig)
{
/*
* XXX we are in a signal handler, we are not allowed to use malloc
* and friends, which is what we do
*/
tmate_info("CRASH, printing stack trace");
/* TODO send stack trace to server */
const char *what = sig == SIGSEGV ? "SIGSEGV" : "SIGABRT";
tmate_info("%s printing stack trace", what);
tmate_print_stack_trace();
tmate_fatal("CRASHED");
/* Reraise */
signal(sig, NULL);
kill(getpid(), sig);
}
void tmate_catch_sigsegv(void)

View File

@ -442,13 +442,6 @@ static void handle_sigchld(__unused int sig)
}
}
static void handle_sigsegv(__unused int sig)
{
tmate_info("CRASH, printing stack trace");
tmate_print_stack_trace();
tmate_fatal("CRASHED");
}
void tmate_ssh_server_main(struct tmate_session *session, const char *keys_dir,
const char *bind_addr, int port)
{
@ -457,7 +450,7 @@ void tmate_ssh_server_main(struct tmate_session *session, const char *keys_dir,
pid_t pid;
int fd;
signal(SIGSEGV, handle_sigsegv);
tmate_catch_sigsegv();
signal(SIGCHLD, handle_sigchld);
bind = prepare_ssh(keys_dir, bind_addr, port);