]> git.ipfire.org Git - thirdparty/bash.git/blame_incremental - sig.h
Bash-4.3 patch 32
[thirdparty/bash.git] / sig.h
... / ...
CommitLineData
1/* sig.h -- header file for signal handler definitions. */
2
3/* Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
5 This file is part of GNU Bash, the Bourne Again SHell.
6
7 Bash is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 Bash is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21/* Make sure that this is included *after* config.h! */
22
23#if !defined (_SIG_H_)
24# define _SIG_H_
25
26#include "stdc.h"
27
28#if !defined (SIG_DFL)
29# include <signal.h> /* for sig_atomic_t */
30#endif
31
32#if !defined (SIGABRT) && defined (SIGIOT)
33# define SIGABRT SIGIOT
34#endif
35
36#define sighandler RETSIGTYPE
37typedef RETSIGTYPE SigHandler __P((int));
38
39#if defined (VOID_SIGHANDLER)
40# define SIGRETURN(n) return
41#else
42# define SIGRETURN(n) return(n)
43#endif /* !VOID_SIGHANDLER */
44
45/* Here is a definition for set_signal_handler () which simply expands to
46 a call to signal () for non-Posix systems. The code for set_signal_handler
47 in the Posix case resides in general.c. */
48#if !defined (HAVE_POSIX_SIGNALS)
49# define set_signal_handler(sig, handler) (SigHandler *)signal (sig, handler)
50#else
51extern SigHandler *set_signal_handler __P((int, SigHandler *)); /* in sig.c */
52#endif /* _POSIX_VERSION */
53
54#if !defined (SIGCHLD) && defined (SIGCLD)
55# define SIGCHLD SIGCLD
56#endif
57
58#if !defined (HAVE_POSIX_SIGNALS) && !defined (sigmask)
59# define sigmask(x) (1 << ((x)-1))
60#endif /* !HAVE_POSIX_SIGNALS && !sigmask */
61
62#if !defined (HAVE_POSIX_SIGNALS)
63# if !defined (SIG_BLOCK)
64# define SIG_BLOCK 2
65# define SIG_SETMASK 3
66# endif /* SIG_BLOCK */
67
68/* sigset_t defined in config.h */
69
70/* Make sure there is nothing inside the signal set. */
71# define sigemptyset(set) (*(set) = 0)
72
73/* Initialize the signal set to hold all signals. */
74# define sigfillset(set) (*set) = sigmask (NSIG) - 1
75
76/* Add SIG to the contents of SET. */
77# define sigaddset(set, sig) *(set) |= sigmask (sig)
78
79/* Delete SIG from signal set SET. */
80# define sigdelset(set, sig) *(set) &= ~sigmask (sig)
81
82/* Is SIG a member of the signal set SET? */
83# define sigismember(set, sig) ((*(set) & sigmask (sig)) != 0)
84
85/* Suspend the process until the reception of one of the signals
86 not present in SET. */
87# define sigsuspend(set) sigpause (*(set))
88#endif /* !HAVE_POSIX_SIGNALS */
89
90/* These definitions are used both in POSIX and non-POSIX implementations. */
91
92#define BLOCK_SIGNAL(sig, nvar, ovar) \
93do { \
94 sigemptyset (&nvar); \
95 sigaddset (&nvar, sig); \
96 sigemptyset (&ovar); \
97 sigprocmask (SIG_BLOCK, &nvar, &ovar); \
98} while (0)
99
100#define UNBLOCK_SIGNAL(ovar) sigprocmask (SIG_SETMASK, &ovar, (sigset_t *) NULL)
101
102#if defined (HAVE_POSIX_SIGNALS)
103# define BLOCK_CHILD(nvar, ovar) BLOCK_SIGNAL (SIGCHLD, nvar, ovar)
104# define UNBLOCK_CHILD(ovar) UNBLOCK_SIGNAL(ovar)
105#else /* !HAVE_POSIX_SIGNALS */
106# define BLOCK_CHILD(nvar, ovar) ovar = sigblock (sigmask (SIGCHLD))
107# define UNBLOCK_CHILD(ovar) sigsetmask (ovar)
108#endif /* !HAVE_POSIX_SIGNALS */
109
110/* Extern variables */
111extern volatile sig_atomic_t sigwinch_received;
112extern volatile sig_atomic_t sigterm_received;
113
114extern int interrupt_immediately; /* no longer used */
115extern int terminate_immediately;
116
117/* Functions from sig.c. */
118extern sighandler termsig_sighandler __P((int));
119extern void termsig_handler __P((int));
120extern sighandler sigint_sighandler __P((int));
121extern void initialize_signals __P((int));
122extern void initialize_terminating_signals __P((void));
123extern void reset_terminating_signals __P((void));
124extern void top_level_cleanup __P((void));
125extern void throw_to_top_level __P((void));
126extern void jump_to_top_level __P((int)) __attribute__((__noreturn__));
127
128extern sighandler sigwinch_sighandler __P((int));
129extern void set_sigwinch_handler __P((void));
130extern void unset_sigwinch_handler __P((void));
131
132extern sighandler sigterm_sighandler __P((int));
133
134/* Functions defined in trap.c. */
135extern SigHandler *set_sigint_handler __P((void));
136extern SigHandler *trap_to_sighandler __P((int));
137extern sighandler trap_handler __P((int));
138
139#endif /* _SIG_H_ */