tadd a quit function and separate it as a signal handler - catpoint - Catpoint simple presenting software.
 (HTM) git clone git://r-36.net/catpoint
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit c21defed8f5b1cdcf8f1360ab81eb28725815489
 (DIR) parent f1929385f7c4fc8d193479a376c5ea0ee6fee8b7
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       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 <20h@r-36.net>
       
       Diffstat:
         catpoint.c                          |      18 +++++++++++-------
       
       1 file changed, 11 insertions(+), 7 deletions(-)
       ---
 (DIR) diff --git a/catpoint.c b/catpoint.c
       t@@ -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;
        
       t@@ -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
       t@@ -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);
       t@@ -190,9 +196,7 @@ again:
                        goto again;
                }
        
       -        /* unmap mem */
       -        exitstatus = 0;
       -        cleanup(0);
       +        cleanup();
        
                return 0;
        }