]> git.ipfire.org Git - thirdparty/bash.git/blame - sig.h
Bash-4.3 patch 32
[thirdparty/bash.git] / sig.h
CommitLineData
ccc6cda3
JA
1/* sig.h -- header file for signal handler definitions. */
2
ac50fbac 3/* Copyright (C) 1994-2013 Free Software Foundation, Inc.
ccc6cda3
JA
4
5 This file is part of GNU Bash, the Bourne Again SHell.
6
3185942a
JA
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.
ccc6cda3 11
3185942a
JA
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.
ccc6cda3 16
3185942a
JA
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*/
ccc6cda3
JA
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
ac50fbac
CR
28#if !defined (SIG_DFL)
29# include <signal.h> /* for sig_atomic_t */
30#endif
31
ccc6cda3
JA
32#if !defined (SIGABRT) && defined (SIGIOT)
33# define SIGABRT SIGIOT
34#endif
35
36#define sighandler RETSIGTYPE
7117c2d2 37typedef RETSIGTYPE SigHandler __P((int));
ccc6cda3
JA
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
7117c2d2 51extern SigHandler *set_signal_handler __P((int, SigHandler *)); /* in sig.c */
ccc6cda3
JA
52#endif /* _POSIX_VERSION */
53
ccc6cda3
JA
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) \
7117c2d2 93do { \
ccc6cda3
JA
94 sigemptyset (&nvar); \
95 sigaddset (&nvar, sig); \
96 sigemptyset (&ovar); \
7117c2d2
JA
97 sigprocmask (SIG_BLOCK, &nvar, &ovar); \
98} while (0)
ccc6cda3 99
ac50fbac
CR
100#define UNBLOCK_SIGNAL(ovar) sigprocmask (SIG_SETMASK, &ovar, (sigset_t *) NULL)
101
ccc6cda3 102#if defined (HAVE_POSIX_SIGNALS)
ac50fbac
CR
103# define BLOCK_CHILD(nvar, ovar) BLOCK_SIGNAL (SIGCHLD, nvar, ovar)
104# define UNBLOCK_CHILD(ovar) UNBLOCK_SIGNAL(ovar)
ccc6cda3
JA
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
95732b49 110/* Extern variables */
ac50fbac
CR
111extern volatile sig_atomic_t sigwinch_received;
112extern volatile sig_atomic_t sigterm_received;
95732b49 113
ac50fbac 114extern int interrupt_immediately; /* no longer used */
0628567a
JA
115extern int terminate_immediately;
116
ccc6cda3 117/* Functions from sig.c. */
0628567a
JA
118extern sighandler termsig_sighandler __P((int));
119extern void termsig_handler __P((int));
ccc6cda3 120extern sighandler sigint_sighandler __P((int));
7117c2d2 121extern void initialize_signals __P((int));
d166f048 122extern void initialize_terminating_signals __P((void));
ccc6cda3 123extern void reset_terminating_signals __P((void));
f1be666c 124extern void top_level_cleanup __P((void));
ccc6cda3 125extern void throw_to_top_level __P((void));
f73dda09 126extern void jump_to_top_level __P((int)) __attribute__((__noreturn__));
ccc6cda3 127
95732b49
JA
128extern sighandler sigwinch_sighandler __P((int));
129extern void set_sigwinch_handler __P((void));
130extern void unset_sigwinch_handler __P((void));
131
ac50fbac
CR
132extern sighandler sigterm_sighandler __P((int));
133
ccc6cda3
JA
134/* Functions defined in trap.c. */
135extern SigHandler *set_sigint_handler __P((void));
e8ce775d
JA
136extern SigHandler *trap_to_sighandler __P((int));
137extern sighandler trap_handler __P((int));
ccc6cda3
JA
138
139#endif /* _SIG_H_ */