1114472Sru/* signals.h -- header to include system dependent signal definitions. 2146515Sru $Id: signals.h,v 1.2 2004/04/11 17:56:46 karl Exp $ 321495Sjmacd 4146515Sru Copyright (C) 1993, 1994, 1995, 1997, 2002, 2004 Free Software Foundation, Inc. 521495Sjmacd 621495Sjmacd This program is free software; you can redistribute it and/or modify 721495Sjmacd it under the terms of the GNU General Public License as published by 821495Sjmacd the Free Software Foundation; either version 2, or (at your option) 921495Sjmacd any later version. 1021495Sjmacd 1121495Sjmacd This program is distributed in the hope that it will be useful, 1221495Sjmacd but WITHOUT ANY WARRANTY; without even the implied warranty of 1321495Sjmacd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1421495Sjmacd GNU General Public License for more details. 1521495Sjmacd 1621495Sjmacd You should have received a copy of the GNU General Public License 1721495Sjmacd along with this program; if not, write to the Free Software 1821495Sjmacd Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 1921495Sjmacd 20146515Sru Originally written by Brian Fox (bfox@ai.mit.edu). */ 2121495Sjmacd 2242660Smarkm#ifndef INFO_SIGNALS_H 2342660Smarkm#define INFO_SIGNALS_H 2421495Sjmacd 2542660Smarkm#include <sys/types.h> 2621495Sjmacd#include <signal.h> 2721495Sjmacd 2842660Smarkm/* For sysV68 --phdm@info.ucl.ac.be. */ 2942660Smarkm#if !defined (SIGCHLD) && defined (SIGCLD) 3042660Smarkm#define SIGCHLD SIGCLD 3142660Smarkm#endif 3242660Smarkm 3321495Sjmacd#if !defined (HAVE_SIGPROCMASK) && !defined (sigmask) 3421495Sjmacd# define sigmask(x) (1 << ((x)-1)) 3521495Sjmacd#endif /* !HAVE_SIGPROCMASK && !sigmask */ 3621495Sjmacd 37146515Sru/* Without SA_NOCLDSTOP, sigset_t might end up being undefined even 38146515Sru though we have sigprocmask, on older systems, according to Nelson 39146515Sru Beebe. The test is from coreutils/sort.c, via Paul Eggert. */ 40146515Sru#if !defined (HAVE_SIGPROCMASK) || !defined (SA_NOCLDSTOP) 4121495Sjmacd# if !defined (SIG_BLOCK) 4221495Sjmacd# define SIG_UNBLOCK 1 4321495Sjmacd# define SIG_BLOCK 2 4421495Sjmacd# define SIG_SETMASK 3 4521495Sjmacd# endif /* SIG_BLOCK */ 4621495Sjmacd 4721495Sjmacd/* Type of a signal set. */ 4821495Sjmacd# define sigset_t int 4921495Sjmacd 5021495Sjmacd/* Make SET have no signals in it. */ 5121495Sjmacd# define sigemptyset(set) (*(set) = (sigset_t)0x0) 5221495Sjmacd 5321495Sjmacd/* Make SET have the full range of signal specifications possible. */ 5421495Sjmacd# define sigfillset(set) (*(set) = (sigset_t)0xffffffffff) 5521495Sjmacd 5621495Sjmacd/* Add SIG to the contents of SET. */ 5721495Sjmacd# define sigaddset(set, sig) *(set) |= sigmask (sig) 5821495Sjmacd 5921495Sjmacd/* Delete SIG from the contents of SET. */ 6021495Sjmacd# define sigdelset(set, sig) *(set) &= ~(sigmask (sig)) 6121495Sjmacd 6221495Sjmacd/* Tell if SET contains SIG. */ 6321495Sjmacd# define sigismember(set, sig) (*(set) & (sigmask (sig))) 6421495Sjmacd 6521495Sjmacd/* Suspend the process until the reception of one of the signals 6621495Sjmacd not present in SET. */ 6721495Sjmacd# define sigsuspend(set) sigpause (*(set)) 6821495Sjmacd#endif /* !HAVE_SIGPROCMASK */ 6921495Sjmacd 7021495Sjmacd#if defined (HAVE_SIGPROCMASK) || defined (HAVE_SIGSETMASK) 7121495Sjmacd/* These definitions are used both in POSIX and non-POSIX implementations. */ 7221495Sjmacd 7321495Sjmacd#define BLOCK_SIGNAL(sig) \ 7421495Sjmacd do { \ 7521495Sjmacd sigset_t nvar, ovar; \ 7621495Sjmacd sigemptyset (&nvar); \ 7721495Sjmacd sigemptyset (&ovar); \ 7821495Sjmacd sigaddset (&nvar, sig); \ 7921495Sjmacd sigprocmask (SIG_BLOCK, &nvar, &ovar); \ 8021495Sjmacd } while (0) 8121495Sjmacd 8221495Sjmacd#define UNBLOCK_SIGNAL(sig) \ 8321495Sjmacd do { \ 8421495Sjmacd sigset_t nvar, ovar; \ 8521495Sjmacd sigemptyset (&ovar); \ 8621495Sjmacd sigemptyset (&nvar); \ 8721495Sjmacd sigaddset (&nvar, sig); \ 8821495Sjmacd sigprocmask (SIG_UNBLOCK, &nvar, &ovar); \ 8921495Sjmacd } while (0) 9021495Sjmacd 9121495Sjmacd#else /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */ 9221495Sjmacd# define BLOCK_SIGNAL(sig) 9321495Sjmacd# define UNBLOCK_SIGNAL(sig) 9421495Sjmacd#endif /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */ 9521495Sjmacd 9642660Smarkm#endif /* not INFO_SIGNALS_H */ 97