]> git.ipfire.org Git - thirdparty/bash.git/blame_incremental - sig.h
updated translations; remove unneeded files
[thirdparty/bash.git] / sig.h
... / ...
CommitLineData
1/* sig.h -- header file for signal handler definitions. */
2
3/* Copyright (C) 1994-2021 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#include <signal.h> /* for sig_atomic_t */
29
30#if !defined (SIGABRT) && defined (SIGIOT)
31# define SIGABRT SIGIOT
32#endif
33
34#define sighandler void
35typedef void SigHandler PARAMS((int));
36
37#define SIGRETURN(n) return
38
39/* Here is a definition for set_signal_handler () which simply expands to
40 a call to signal () for non-Posix systems. The code for set_signal_handler
41 in the Posix case resides in general.c. */
42#if !defined (HAVE_POSIX_SIGNALS)
43# define set_signal_handler(sig, handler) (SigHandler *)signal (sig, handler)
44#else
45extern SigHandler *set_signal_handler PARAMS((int, SigHandler *)); /* in sig.c */
46#endif /* _POSIX_VERSION */
47
48#if !defined (SIGCHLD) && defined (SIGCLD)
49# define SIGCHLD SIGCLD
50#endif
51
52#if !defined (HAVE_POSIX_SIGNALS) && !defined (sigmask)
53# define sigmask(x) (1 << ((x)-1))
54#endif /* !HAVE_POSIX_SIGNALS && !sigmask */
55
56#if !defined (HAVE_POSIX_SIGNALS)
57# if !defined (SIG_BLOCK)
58# define SIG_BLOCK 2
59# define SIG_SETMASK 3
60# endif /* SIG_BLOCK */
61
62/* sigset_t defined in config.h */
63
64/* Make sure there is nothing inside the signal set. */
65# define sigemptyset(set) (*(set) = 0)
66
67/* Initialize the signal set to hold all signals. */
68# define sigfillset(set) (*set) = sigmask (NSIG) - 1
69
70/* Add SIG to the contents of SET. */
71# define sigaddset(set, sig) *(set) |= sigmask (sig)
72
73/* Delete SIG from signal set SET. */
74# define sigdelset(set, sig) *(set) &= ~sigmask (sig)
75
76/* Is SIG a member of the signal set SET? */
77# define sigismember(set, sig) ((*(set) & sigmask (sig)) != 0)
78
79/* Suspend the process until the reception of one of the signals
80 not present in SET. */
81# define sigsuspend(set) sigpause (*(set))
82#endif /* !HAVE_POSIX_SIGNALS */
83
84/* These definitions are used both in POSIX and non-POSIX implementations. */
85
86#define BLOCK_SIGNAL(sig, nvar, ovar) \
87do { \
88 sigemptyset (&nvar); \
89 sigaddset (&nvar, sig); \
90 sigemptyset (&ovar); \
91 sigprocmask (SIG_BLOCK, &nvar, &ovar); \
92} while (0)
93
94#define UNBLOCK_SIGNAL(ovar) sigprocmask (SIG_SETMASK, &ovar, (sigset_t *) NULL)
95
96#if defined (HAVE_POSIX_SIGNALS)
97# define BLOCK_CHILD(nvar, ovar) BLOCK_SIGNAL (SIGCHLD, nvar, ovar)
98# define UNBLOCK_CHILD(ovar) UNBLOCK_SIGNAL(ovar)
99#else /* !HAVE_POSIX_SIGNALS */
100# define BLOCK_CHILD(nvar, ovar) ovar = sigblock (sigmask (SIGCHLD))
101# define UNBLOCK_CHILD(ovar) sigsetmask (ovar)
102#endif /* !HAVE_POSIX_SIGNALS */
103
104/* Extern variables */
105extern volatile sig_atomic_t sigwinch_received;
106extern volatile sig_atomic_t sigterm_received;
107
108extern int interrupt_immediately; /* no longer used */
109extern int terminate_immediately;
110
111/* Functions from sig.c. */
112extern sighandler termsig_sighandler PARAMS((int));
113extern void termsig_handler PARAMS((int));
114extern sighandler sigint_sighandler PARAMS((int));
115extern void initialize_signals PARAMS((int));
116extern void initialize_terminating_signals PARAMS((void));
117extern void reset_terminating_signals PARAMS((void));
118extern void top_level_cleanup PARAMS((void));
119extern void throw_to_top_level PARAMS((void));
120extern void jump_to_top_level PARAMS((int)) __attribute__((__noreturn__));
121extern void restore_sigmask PARAMS((void));
122
123extern sighandler sigwinch_sighandler PARAMS((int));
124extern void set_sigwinch_handler PARAMS((void));
125extern void unset_sigwinch_handler PARAMS((void));
126
127extern sighandler sigterm_sighandler PARAMS((int));
128
129/* Functions defined in trap.c. */
130extern SigHandler *set_sigint_handler PARAMS((void));
131extern SigHandler *trap_to_sighandler PARAMS((int));
132extern sighandler trap_handler PARAMS((int));
133
134extern int block_trapped_signals PARAMS((sigset_t *, sigset_t *));
135extern int unblock_trapped_signals PARAMS((sigset_t *));
136#endif /* _SIG_H_ */