aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fbi.c37
-rw-r--r--fbtools.c40
-rw-r--r--fbtools.h1
3 files changed, 36 insertions, 42 deletions
diff --git a/fbi.c b/fbi.c
index 3436113..e423efa 100644
--- a/fbi.c
+++ b/fbi.c
@@ -1408,6 +1408,41 @@ static void cleanup_and_exit(int code)
exit(code);
}
+static jmp_buf fb_fatal_cleanup;
+
+static void catch_exit_signal(int signal)
+{
+ siglongjmp(fb_fatal_cleanup,signal);
+}
+
+static void exit_signals_init(void)
+{
+ struct sigaction act,old;
+ int termsig;
+
+ memset(&act,0,sizeof(act));
+ act.sa_handler = catch_exit_signal;
+ sigemptyset(&act.sa_mask);
+ sigaction(SIGINT, &act,&old);
+ sigaction(SIGQUIT,&act,&old);
+ sigaction(SIGTERM,&act,&old);
+
+ sigaction(SIGABRT,&act,&old);
+ sigaction(SIGTSTP,&act,&old);
+
+ sigaction(SIGBUS, &act,&old);
+ sigaction(SIGILL, &act,&old);
+ sigaction(SIGSEGV,&act,&old);
+
+ if (0 == (termsig = sigsetjmp(fb_fatal_cleanup,0)))
+ return;
+
+ /* cleanup */
+ gfx->cleanup_display();
+ fprintf(stderr,"Oops: %s\n",strsignal(termsig));
+ exit(42);
+}
+
int
main(int argc, char *argv[])
{
@@ -1494,7 +1529,7 @@ main(int argc, char *argv[])
gfx = fb_init(cfg_get_str(O_DEVICE),
cfg_get_str(O_VIDEO_MODE),
GET_VT());
- fb_catch_exit_signals();
+ exit_signals_init();
fb_switch_init();
shadow_init(gfx);
signal(SIGTSTP,SIG_IGN);
diff --git a/fbtools.c b/fbtools.c
index 708dbe4..ef0e160 100644
--- a/fbtools.c
+++ b/fbtools.c
@@ -540,43 +540,3 @@ gfxstate* fb_init(char *device, char *mode, int vt)
fb_cleanup_display();
exit(1);
}
-
-/* -------------------------------------------------------------------- */
-/* handle fatal errors */
-
-static jmp_buf fb_fatal_cleanup;
-
-static void
-fb_catch_exit_signal(int signal)
-{
- siglongjmp(fb_fatal_cleanup,signal);
-}
-
-void
-fb_catch_exit_signals(void)
-{
- struct sigaction act,old;
- int termsig;
-
- memset(&act,0,sizeof(act));
- act.sa_handler = fb_catch_exit_signal;
- sigemptyset(&act.sa_mask);
- sigaction(SIGINT, &act,&old);
- sigaction(SIGQUIT,&act,&old);
- sigaction(SIGTERM,&act,&old);
-
- sigaction(SIGABRT,&act,&old);
- sigaction(SIGTSTP,&act,&old);
-
- sigaction(SIGBUS, &act,&old);
- sigaction(SIGILL, &act,&old);
- sigaction(SIGSEGV,&act,&old);
-
- if (0 == (termsig = sigsetjmp(fb_fatal_cleanup,0)))
- return;
-
- /* cleanup */
- fb_cleanup_display();
- fprintf(stderr,"Oops: %s\n",strsignal(termsig));
- exit(42);
-}
diff --git a/fbtools.h b/fbtools.h
index 1636654..41cd1d7 100644
--- a/fbtools.h
+++ b/fbtools.h
@@ -10,7 +10,6 @@ extern int fb_switch_state;
/* init + cleanup */
gfxstate *fb_init(char *device, char *mode, int vt);
-void fb_catch_exit_signals(void);
void fb_memset(void *addr, int c, size_t len);
/* console switching */