/[monit]/monit/signal.c
ViewVC logotype

Diff of /monit/signal.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by chopp, Wed Aug 13 22:18:43 2003 UTC revision 1.7 by hauk, Thu Aug 14 21:43:14 2003 UTC
# Line 32  Line 32 
32  /**  /**
33   *  Signal handeling routines.   *  Signal handeling routines.
34   *   *
35   *  @author W. Richard Stevens <heaven>   *  @author W. Richard Stevens
36   *  @author Jan-Henrik Haukeland, <hauk@tildeslash.com>   *  @author Jan-Henrik Haukeland, <hauk@tildeslash.com>
37   *       *    
38   *  @version \$Id$   *  @version \$Id$
# Line 74  Sigfunc *signal(int signo, Sigfunc *func Line 74  Sigfunc *signal(int signo, Sigfunc *func
74    
75    
76  /**  /**
77   * Set a handler for the alarm signal,   * Set a collective thread signal block for signals honored by monit
78   * SIGALRM using sigaction.   * @param new The signal mask to use for the block
79     * @param old The signal mask used to save the previous mask
80   */   */
81  void set_alarm_handler(void *func) {  void set_signal_block(sigset_t *new, sigset_t *old) {
82    
83    struct sigaction sa;    sigemptyset(new);
84      sigaddset(new, SIGINT);
85      sigaddset(new, SIGUSR1);
86      sigaddset(new, SIGTERM);
87      pthread_sigmask(SIG_BLOCK, new, old);
88    
89    sa.sa_handler= func;  }
90    sa.sa_flags= 0;  
91    sigemptyset(&sa.sa_mask);  
92    sigaction(SIGALRM, &sa, NULL);  /**
93     * Set the thread signal mask back to the old mask
94     * @param old The signal mask to restore
95     */
96    void unset_signal_block(sigset_t *old) {
97    
98      pthread_sigmask(SIG_SETMASK, old, NULL);
99        
100  }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26