Commit | Line | Data |
---|---|---|
9ab9afa9 | 1 | /* syssignal.h - System-dependent definitions for signals. |
68c45bf0 | 2 | Copyright (C) 1993, 1999 Free Software Foundation, Inc. |
9ab9afa9 JB |
3 | |
4 | This file is part of GNU Emacs. | |
5 | ||
6 | GNU Emacs is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
7c938215 | 8 | the Free Software Foundation; either version 2, or (at your option) |
9ab9afa9 JB |
9 | any later version. |
10 | ||
11 | GNU Emacs is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU Emacs; see the file COPYING. If not, write to | |
3b7ad313 EN |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. */ | |
9ab9afa9 | 20 | |
2b98b088 TTN |
21 | extern void init_signals P_ ((void)); |
22 | ||
9ab9afa9 | 23 | #ifdef POSIX_SIGNALS |
00eaaa32 | 24 | |
c3aa5fec | 25 | /* Don't #include <signal.h>. That header should always be #included |
cf026b25 JB |
26 | before "config.h", because some configuration files (like s/hpux.h) |
27 | indicate that SIGIO doesn't work by #undef-ing SIGIO. If this file | |
28 | #includes <signal.h>, then that will re-#define SIGIO and confuse | |
29 | things. */ | |
4d553a13 | 30 | /* XXX This is not correct anymore, there is a BROKEN_SIGIO macro. */ |
00eaaa32 | 31 | |
9ab9afa9 JB |
32 | #define SIGMASKTYPE sigset_t |
33 | ||
34 | #define SIGEMPTYMASK (empty_mask) | |
35 | #define SIGFULLMASK (full_mask) | |
47b682b7 | 36 | extern sigset_t empty_mask, full_mask; |
9ab9afa9 | 37 | |
1b1f8f85 | 38 | /* POSIX pretty much destroys any possibility of writing sigmask as a |
47b682b7 AS |
39 | macro in standard C. We always define our own version because the |
40 | predefined macro in Glibc 2.1 is only provided for compatility for old | |
41 | programs that use int as signal mask type. */ | |
42 | #undef sigmask | |
1b1f8f85 JB |
43 | #ifdef __GNUC__ |
44 | #define sigmask(SIG) \ | |
45 | ({ \ | |
46 | sigset_t _mask; \ | |
47 | sigemptyset (&_mask); \ | |
48 | sigaddset (&_mask, SIG); \ | |
49 | _mask; \ | |
50 | }) | |
985a35a3 | 51 | #else /* ! defined (__GNUC__) */ |
9bd67a37 | 52 | extern sigset_t sys_sigmask (); |
1b1f8f85 | 53 | #define sigmask(SIG) (sys_sigmask (SIG)) |
985a35a3 | 54 | #endif /* ! defined (__GNUC__) */ |
1b1f8f85 | 55 | |
47b682b7 AS |
56 | #undef sigpause |
57 | #define sigpause(MASK) sigsuspend (&(MASK)) | |
9f910b50 | 58 | |
69037d5a RS |
59 | #define sigblock(SIG) sys_sigblock (SIG) |
60 | #define sigunblock(SIG) sys_sigunblock (SIG) | |
cc210d67 | 61 | #ifndef sigsetmask |
69037d5a | 62 | #define sigsetmask(SIG) sys_sigsetmask (SIG) |
cc210d67 | 63 | #endif |
9ab9afa9 JB |
64 | #define sighold(SIG) ONLY_USED_IN_BSD_4_1 |
65 | #define sigrelse(SIG) ONLY_USED_IN_BSD_4_1 | |
6c8a1e24 | 66 | #undef signal |
9c063f29 | 67 | #define signal(SIG,ACT) sys_signal(SIG,ACT) |
9ab9afa9 | 68 | |
00eaaa32 | 69 | /* Whether this is what all systems want or not, this is what |
69037d5a | 70 | appears to be assumed in the source, for example data.c:arith_error. */ |
667da7f5 | 71 | typedef RETSIGTYPE (*signal_handler_t) (/*int*/); |
00eaaa32 | 72 | |
030f4475 AS |
73 | signal_handler_t sys_signal P_ ((int signal_number, signal_handler_t action)); |
74 | sigset_t sys_sigblock P_ ((sigset_t new_mask)); | |
75 | sigset_t sys_sigunblock P_ ((sigset_t new_mask)); | |
76 | sigset_t sys_sigsetmask P_ ((sigset_t new_mask)); | |
9ab9afa9 | 77 | |
69037d5a | 78 | #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG) |
9ab9afa9 | 79 | |
985a35a3 JB |
80 | #else /* ! defined (POSIX_SIGNALS) */ |
81 | #ifdef USG5_4 | |
82 | ||
094d2b0e GM |
83 | extern SIGMASKTYPE sigprocmask_set; |
84 | ||
69037d5a | 85 | #ifndef sigblock |
094d2b0e GM |
86 | #define sigblock(sig) \ |
87 | (sigprocmask_set = SIGEMPTYMASK | (sig), \ | |
88 | sigprocmask (SIG_BLOCK, &sigprocmask_set, NULL)) | |
69037d5a RS |
89 | #endif |
90 | ||
fe54008f | 91 | #ifndef sigunblock |
094d2b0e GM |
92 | #define sigunblock(sig) \ |
93 | (sigprocmask_set = SIGFULLMASK & ~(sig), \ | |
94 | sigprocmask (SIG_SETMASK, &sigprocmask_set, NULL)) | |
fe54008f | 95 | #endif |
985a35a3 JB |
96 | |
97 | #else | |
98 | #ifdef USG | |
99 | ||
fe54008f | 100 | #ifndef sigunblock |
177c0ea7 | 101 | #define sigunblock(sig) |
fe54008f | 102 | #endif |
985a35a3 JB |
103 | |
104 | #else | |
9ab9afa9 | 105 | |
fe54008f | 106 | #ifndef sigunblock |
9ab9afa9 JB |
107 | #define sigunblock(SIG) \ |
108 | { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); } | |
fe54008f | 109 | #endif |
9ab9afa9 | 110 | |
985a35a3 JB |
111 | #endif /* ! defined (USG) */ |
112 | #endif /* ! defined (USG5_4) */ | |
113 | #endif /* ! defined (POSIX_SIGNALS) */ | |
9ab9afa9 JB |
114 | |
115 | #ifndef SIGMASKTYPE | |
116 | #define SIGMASKTYPE int | |
117 | #endif | |
118 | ||
119 | #ifndef SIGEMPTYMASK | |
1b1f8f85 JB |
120 | #define SIGEMPTYMASK (0) |
121 | #endif | |
122 | ||
123 | #ifndef SIGFULLMASK | |
124 | #define SIGFULLMASK (0xffffffff) | |
9ab9afa9 JB |
125 | #endif |
126 | ||
127 | #ifndef sigmask | |
128 | #define sigmask(no) (1L << ((no) - 1)) | |
129 | #endif | |
130 | ||
1b1f8f85 JB |
131 | #ifndef sigunblock |
132 | #define sigunblock(SIG) \ | |
133 | { SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); } | |
134 | #endif | |
135 | ||
1b1f8f85 JB |
136 | #ifndef BSD4_1 |
137 | #define sigfree() sigsetmask (SIGEMPTYMASK) | |
ea973b10 | 138 | #endif /* not BSD4_1 */ |
1b1f8f85 | 139 | |
68c45bf0 PE |
140 | #if defined (SIGINFO) && defined (BROKEN_SIGINFO) |
141 | #undef SIGINFO | |
142 | #endif | |
143 | #if defined (SIGIO) && defined (BROKEN_SIGIO) | |
144 | #undef SIGIO | |
145 | #endif | |
146 | #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL) | |
147 | #undef SIGPOLL | |
148 | #endif | |
149 | #if defined (SIGTSTP) && defined (BROKEN_SIGTSTP) | |
150 | #undef SIGTSTP | |
151 | #endif | |
152 | #if defined (SIGURG) && defined (BROKEN_SIGURG) | |
153 | #undef SIGURG | |
154 | #endif | |
4e677396 KH |
155 | #if defined (SIGAIO) && defined (BROKEN_SIGAIO) |
156 | #undef SIGAIO | |
157 | #endif | |
158 | #if defined (SIGPTY) && defined (BROKEN_SIGPTY) | |
159 | #undef SIGPTY | |
160 | #endif | |
161 | ||
68c45bf0 PE |
162 | |
163 | #if NSIG < NSIG_MINIMUM | |
164 | # ifdef NSIG | |
165 | # undef NSIG | |
166 | # endif | |
167 | # define NSIG NSIG_MINIMUM | |
168 | #endif | |
169 | ||
9ab9afa9 JB |
170 | #ifdef BSD4_1 |
171 | #define SIGIO SIGTINT | |
645280b7 | 172 | /* sigfree is in sysdep.c */ |
ea973b10 | 173 | #endif /* BSD4_1 */ |
9ab9afa9 JB |
174 | |
175 | /* On bsd, [man says] kill does not accept a negative number to kill a pgrp. | |
176 | Must do that using the killpg call. */ | |
6df54671 | 177 | #ifdef BSD_SYSTEM |
9ab9afa9 JB |
178 | #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo))) |
179 | #else | |
57d65592 | 180 | #ifdef WINDOWSNT |
f405affb | 181 | #define EMACS_KILLPG(gid, signo) (kill (gid, signo)) |
57d65592 | 182 | #else |
9ab9afa9 JB |
183 | #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo))) |
184 | #endif | |
57d65592 | 185 | #endif |
9ab9afa9 JB |
186 | |
187 | /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals | |
188 | testing SIGCHLD. */ | |
9ab9afa9 JB |
189 | #ifndef VMS |
190 | #ifdef SIGCLD | |
191 | #ifndef SIGCHLD | |
192 | #define SIGCHLD SIGCLD | |
985a35a3 JB |
193 | #endif /* SIGCHLD */ |
194 | #endif /* ! defined (SIGCLD) */ | |
195 | #endif /* VMS */ | |
68c45bf0 PE |
196 | |
197 | #ifndef HAVE_STRSIGNAL | |
198 | /* strsignal is in sysdep.c */ | |
199 | char *strsignal (); | |
200 | #endif | |
ab5796a9 MB |
201 | |
202 | /* arch-tag: 4580e86a-340d-4574-9e11-a742b6e1a152 | |
203 | (do not change this comment) */ |