From 9127db5e322c1b0cd57adf90e8cfefad66020fe2 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Mon, 5 Aug 2019 08:06:19 +0100 Subject: remove atexit and replace exit() with cleanup() --- gramscii.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'gramscii.c') diff --git a/gramscii.c b/gramscii.c index 9a6ef59..6b40009 100644 --- a/gramscii.c +++ b/gramscii.c @@ -39,11 +39,7 @@ void cleanup(int s){ dump_lines(screen, stdout); tcsetattr(0, TCSANOW, &t1); fflush(stdout); - exit(0); -} - -void exit_cleanup(void){ - cleanup(0); + exit(s); } /*** Initialisation ***/ @@ -54,7 +50,6 @@ void init(){ signal(SIGINT, cleanup); signal(SIGTERM, cleanup); signal(SIGQUIT, cleanup); - atexit(exit_cleanup); tcgetattr(0, &t1); t2 = t1; @@ -132,7 +127,7 @@ void commands(FILE *fc){ case 'q': check_modified(fc);/** FALLTHROUGH **/ case 'Q': - exit(0); + cleanup(0); break; } } @@ -147,7 +142,7 @@ void commands(FILE *fc){ void usage(){ fprintf(stderr, "Usage: %s [-s] [-h] [file ...]\n", argv0); - exit(1); + cleanup(1); } -- cgit v1.2.3