summaryrefslogtreecommitdiff
path: root/gramscii.c
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2019-08-05 08:06:19 +0100
committerKatolaZ <katolaz@freaknet.org>2019-08-05 08:06:19 +0100
commit9127db5e322c1b0cd57adf90e8cfefad66020fe2 (patch)
treea654d8c13225cb91a22d34626047a5c9eb24fa4f /gramscii.c
parent6bf74b8e63315aeeac6fe4307e9e2679d334aca3 (diff)
remove atexit and replace exit() with cleanup()
Diffstat (limited to 'gramscii.c')
-rw-r--r--gramscii.c11
1 files changed, 3 insertions, 8 deletions
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);
}