"Fossies" - the Fresh Open Source Software Archive

Member "imapfilter-2.8.2/src/signal.c" (26 Dec 2023, 1052 Bytes) of package /linux/privat/imapfilter-2.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "signal.c" see the Fossies "Dox" file reference documentation.

    1 #include <signal.h>
    2 
    3 #include "imapfilter.h"
    4 
    5 
    6 void signal_handler(int sig);
    7 void user_signal_handler(int sig);
    8 
    9 
   10 /*
   11  * Catch signals that cause program's termination.
   12  */
   13 void
   14 catch_signals(void)
   15 {
   16 
   17     signal(SIGINT, signal_handler);
   18     signal(SIGQUIT, signal_handler);
   19     signal(SIGTERM, signal_handler);
   20 }
   21 
   22 
   23 /*
   24  * Reset signals to default action.
   25  */
   26 void
   27 release_signals(void)
   28 {
   29 
   30     signal(SIGINT, SIG_DFL);
   31     signal(SIGQUIT, SIG_DFL);
   32     signal(SIGTERM, SIG_DFL);
   33 }
   34 
   35 
   36 /*
   37  * Signal handler for signals that cause program's termination.
   38  */
   39 void
   40 signal_handler(int sig)
   41 {
   42 
   43     release_signals();
   44 
   45     fatal(ERROR_SIGNAL, "killed by signal %d\n", sig);
   46 }
   47 
   48 
   49 /*
   50  * Ignore user-defined signals.
   51  */
   52 void
   53 ignore_user_signals(void)
   54 {
   55 
   56     signal(SIGUSR1, SIG_IGN);
   57     signal(SIGUSR2, SIG_IGN);
   58 }
   59 
   60 
   61 /*
   62  * Catch user-defined signals.
   63  */
   64 void
   65 catch_user_signals(void)
   66 {
   67 
   68     signal(SIGUSR1, user_signal_handler);
   69     signal(SIGUSR2, user_signal_handler);
   70 }
   71 
   72 
   73 /*
   74  * Signal handler for user-defined signals.
   75  */
   76 void
   77 user_signal_handler(int sig)
   78 {
   79 
   80     (void)sig;
   81     ignore_user_signals();
   82 }