2 Unix SMB/Netbios implementation.
4 signal handling functions
6 Copyright (C) Andrew Tridgell 1998
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /****************************************************************************
28 ****************************************************************************/
29 static void sig_cld(int signum)
31 while (sys_waitpid((pid_t)-1,(int *)NULL, WNOHANG) > 0) ;
33 CatchSignal(SIGCLD, sig_cld);
38 /*******************************************************************
40 ********************************************************************/
41 void BlockSignals(BOOL block,int signum)
43 #ifdef HAVE_SIGPROCMASK
46 sigaddset(&set,signum);
47 sigprocmask(block?SIG_BLOCK:SIG_UNBLOCK,&set,NULL);
48 #elif defined(HAVE_SIGBLOCK)
49 int block_mask = sigmask(signum);
50 static int oldmask = 0;
52 oldmask = sigblock(block_mask);
57 /* yikes! This platform can't block signals? */
60 DEBUG(0,("WARNING: No signal blocking available\n"));
68 /*******************************************************************
69 catch a signal. This should implement the following semantics:
71 1) the handler remains installed after being called
72 2) the signal should be blocked during handler execution
73 ********************************************************************/
74 void CatchSignal(int signum,void (*handler)(int ))
79 memset(&act, 0, sizeof(act));
81 act.sa_handler = handler;
83 act.sa_flags = SA_RESTART;
85 sigemptyset(&act.sa_mask);
86 sigaddset(&act.sa_mask,signum);
87 sigaction(signum,&act,NULL);
89 /* FIXME: need to handle sigvec and systems with broken signal() */
90 signal(signum, handler);
96 /*******************************************************************
97 ignore SIGCLD via whatever means is necessary for this OS
98 ********************************************************************/
101 CatchSignal(SIGCLD, sig_cld);