Skip to content

Commit

Permalink
Unify tmate-debug.c with tmate-ssh-server
Browse files Browse the repository at this point in the history
  • Loading branch information
nviennot committed Nov 10, 2019
1 parent 9fc6e96 commit e5f6e68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tmate-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

void tmate_print_stack_trace(void) {}
void tmate_catch_sigsegv(void) {}
void tmate_preload_trace_lib(void) {}

#else

Expand Down Expand Up @@ -84,8 +85,7 @@ void tmate_print_stack_trace(void)
free (strings);
}


static void handle_crash(__unused int sig)
static void handle_crash(int sig)
{
/* TODO send stack trace to server */
const char *what = sig == SIGSEGV ? "SIGSEGV" : "SIGABRT";
Expand All @@ -102,4 +102,11 @@ void tmate_catch_sigsegv(void)
signal(SIGSEGV, handle_crash);
signal(SIGABRT, handle_crash);
}

void tmate_preload_trace_lib(void)
{
void *array[1];
backtrace(array, 1);
}

#endif
1 change: 1 addition & 0 deletions tmate.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ extern void tmate_reconnect_session(struct tmate_session *session, const char *m
/* tmate-debug.c */
extern void tmate_print_stack_trace(void);
extern void tmate_catch_sigsegv(void);
extern void tmate_preload_trace_lib(void);

/* tmate-msg.c */

Expand Down

0 comments on commit e5f6e68

Please sign in to comment.