Introduction
Introduction Statistics Contact Development Disclaimer Help
add a quit function and separate it as a signal handler - catpoint - Catpoint s…
git clone git://bitreich.org/catpoint/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrin…
Log
Files
Refs
Tags
README
LICENSE
---
commit c21defed8f5b1cdcf8f1360ab81eb28725815489
parent f1929385f7c4fc8d193479a376c5ea0ee6fee8b7
Author: Hiltjo Posthuma <[email protected]>
Date: Sat, 29 May 2021 17:54:38 +0200
add a quit function and separate it as a signal handler
* This will be useful for a follow-up commit too.
* Remove the unnecesary exitstatus variable.
Signed-off-by: Christoph Lohmann <[email protected]>
Diffstat:
M catpoint.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/catpoint.c b/catpoint.c
@@ -15,7 +15,7 @@
#include <unistd.h>
char *currentslidep, **slidefiles; /* the slides */
-int nslides, currentslide, currentslidelen, exitstatus = 1;
+int nslides, currentslide, currentslidelen;
volatile sig_atomic_t slidechanged = 1;
@@ -30,12 +30,18 @@ unloadcurrentslide(void)
}
void
-cleanup(int sig)
+cleanup(void)
{
unloadcurrentslide();
endwin(); /* restore terminal */
- exit(exitstatus);
+}
+
+void
+quit(int sig)
+{
+ cleanup();
+ exit(0);
}
void
@@ -82,7 +88,7 @@ setsignal()
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
- sa.sa_handler = cleanup;
+ sa.sa_handler = quit;
sigaction(SIGINT, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
@@ -190,9 +196,7 @@ again:
goto again;
}
- /* unmap mem */
- exitstatus = 0;
- cleanup(0);
+ cleanup();
return 0;
}
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.