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. */ | |
00eaaa32 | 30 | |
9ab9afa9 JB |
31 | #define SIGMASKTYPE sigset_t |
32 | ||
33 | #define SIGEMPTYMASK (empty_mask) | |
34 | #define SIGFULLMASK (full_mask) | |
47b682b7 | 35 | extern sigset_t empty_mask, full_mask; |
9ab9afa9 | 36 | |
1b1f8f85 | 37 | /* POSIX pretty much destroys any possibility of writing sigmask as a |
47b682b7 AS |
38 | macro in standard C. We always define our own version because the |
39 | predefined macro in Glibc 2.1 is only provided for compatility for old | |
40 | programs that use int as signal mask type. */ | |
41 | #undef sigmask | |
1b1f8f85 JB |
42 | #ifdef __GNUC__ |
43 | #define sigmask(SIG) \ | |
44 | ({ \ | |
45 | sigset_t _mask; \ | |
46 | sigemptyset (&_mask); \ | |
47 | sigaddset (&_mask, SIG); \ | |
48 | _mask; \ | |
49 | }) | |
985a35a3 | 50 | #else /* ! defined (__GNUC__) */ |
9bd67a37 | 51 | extern sigset_t sys_sigmask (); |
1b1f8f85 | 52 | #define sigmask(SIG) (sys_sigmask (SIG)) |
985a35a3 | 53 | #endif /* ! defined (__GNUC__) */ |
1b1f8f85 | 54 | |
47b682b7 AS |
55 | #undef sigpause |
56 | #define sigpause(MASK) sigsuspend (&(MASK)) | |
9f910b50 | 57 | |
69037d5a RS |
58 | #define sigblock(SIG) sys_sigblock (SIG) |
59 | #define sigunblock(SIG) sys_sigunblock (SIG) | |
cc210d67 | 60 | #ifndef sigsetmask |
69037d5a | 61 | #define sigsetmask(SIG) sys_sigsetmask (SIG) |
cc210d67 | 62 | #endif |
9ab9afa9 JB |
63 | #define sighold(SIG) ONLY_USED_IN_BSD_4_1 |
64 | #define sigrelse(SIG) ONLY_USED_IN_BSD_4_1 | |
6c8a1e24 | 65 | #undef signal |
9c063f29 | 66 | #define signal(SIG,ACT) sys_signal(SIG,ACT) |
9ab9afa9 | 67 | |
00eaaa32 | 68 | /* Whether this is what all systems want or not, this is what |
69037d5a | 69 | appears to be assumed in the source, for example data.c:arith_error. */ |
667da7f5 | 70 | typedef RETSIGTYPE (*signal_handler_t) (/*int*/); |
00eaaa32 | 71 | |
030f4475 AS |
72 | signal_handler_t sys_signal P_ ((int signal_number, signal_handler_t action)); |
73 | sigset_t sys_sigblock P_ ((sigset_t new_mask)); | |
74 | sigset_t sys_sigunblock P_ ((sigset_t new_mask)); | |
75 | sigset_t sys_sigsetmask P_ ((sigset_t new_mask)); | |
9ab9afa9 | 76 | |
69037d5a | 77 | #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG) |
9ab9afa9 | 78 | |
985a35a3 JB |
79 | #else /* ! defined (POSIX_SIGNALS) */ |
80 | #ifdef USG5_4 | |
81 | ||
094d2b0e GM |
82 | extern SIGMASKTYPE sigprocmask_set; |
83 | ||
69037d5a | 84 | #ifndef sigblock |
094d2b0e GM |
85 | #define sigblock(sig) \ |
86 | (sigprocmask_set = SIGEMPTYMASK | (sig), \ | |
87 | sigprocmask (SIG_BLOCK, &sigprocmask_set, NULL)) | |
69037d5a RS |
88 | #endif |
89 | ||
fe54008f | 90 | #ifndef sigunblock |
094d2b0e GM |
91 | #define sigunblock(sig) \ |
92 | (sigprocmask_set = SIGFULLMASK & ~(sig), \ | |
93 | sigprocmask (SIG_SETMASK, &sigprocmask_set, NULL)) | |
fe54008f | 94 | #endif |
985a35a3 JB |
95 | |
96 | #else | |
97 | #ifdef USG | |
98 | ||
fe54008f | 99 | #ifndef sigunblock |
177c0ea7 | 100 | #define sigunblock(sig) |
fe54008f | 101 | #endif |
985a35a3 JB |
102 | |
103 | #else | |
9ab9afa9 | 104 | |
fe54008f | 105 | #ifndef sigunblock |
9ab9afa9 JB |
106 | #define sigunblock(SIG) \ |
107 | { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); } | |
fe54008f | 108 | #endif |
9ab9afa9 | 109 | |
985a35a3 JB |
110 | #endif /* ! defined (USG) */ |
111 | #endif /* ! defined (USG5_4) */ | |
112 | #endif /* ! defined (POSIX_SIGNALS) */ | |
9ab9afa9 JB |
113 | |
114 | #ifndef SIGMASKTYPE | |
115 | #define SIGMASKTYPE int | |
116 | #endif | |
117 | ||
118 | #ifndef SIGEMPTYMASK | |
1b1f8f85 JB |
119 | #define SIGEMPTYMASK (0) |
120 | #endif | |
121 | ||
122 | #ifndef SIGFULLMASK | |
123 | #define SIGFULLMASK (0xffffffff) | |
9ab9afa9 JB |
124 | #endif |
125 | ||
126 | #ifndef sigmask | |
127 | #define sigmask(no) (1L << ((no) - 1)) | |
128 | #endif | |
129 | ||
1b1f8f85 JB |
130 | #ifndef sigunblock |
131 | #define sigunblock(SIG) \ | |
132 | { SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); } | |
133 | #endif | |
134 | ||
1b1f8f85 JB |
135 | #ifndef BSD4_1 |
136 | #define sigfree() sigsetmask (SIGEMPTYMASK) | |
ea973b10 | 137 | #endif /* not BSD4_1 */ |
1b1f8f85 | 138 | |
68c45bf0 PE |
139 | #if defined (SIGINFO) && defined (BROKEN_SIGINFO) |
140 | #undef SIGINFO | |
141 | #endif | |
142 | #if defined (SIGIO) && defined (BROKEN_SIGIO) | |
143 | #undef SIGIO | |
144 | #endif | |
145 | #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL) | |
146 | #undef SIGPOLL | |
147 | #endif | |
148 | #if defined (SIGTSTP) && defined (BROKEN_SIGTSTP) | |
149 | #undef SIGTSTP | |
150 | #endif | |
151 | #if defined (SIGURG) && defined (BROKEN_SIGURG) | |
152 | #undef SIGURG | |
153 | #endif | |
4e677396 KH |
154 | #if defined (SIGAIO) && defined (BROKEN_SIGAIO) |
155 | #undef SIGAIO | |
156 | #endif | |
157 | #if defined (SIGPTY) && defined (BROKEN_SIGPTY) | |
158 | #undef SIGPTY | |
159 | #endif | |
160 | ||
68c45bf0 PE |
161 | |
162 | #if NSIG < NSIG_MINIMUM | |
163 | # ifdef NSIG | |
164 | # undef NSIG | |
165 | # endif | |
166 | # define NSIG NSIG_MINIMUM | |
167 | #endif | |
168 | ||
9ab9afa9 JB |
169 | #ifdef BSD4_1 |
170 | #define SIGIO SIGTINT | |
645280b7 | 171 | /* sigfree is in sysdep.c */ |
ea973b10 | 172 | #endif /* BSD4_1 */ |
9ab9afa9 JB |
173 | |
174 | /* On bsd, [man says] kill does not accept a negative number to kill a pgrp. | |
175 | Must do that using the killpg call. */ | |
6df54671 | 176 | #ifdef BSD_SYSTEM |
9ab9afa9 JB |
177 | #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo))) |
178 | #else | |
57d65592 | 179 | #ifdef WINDOWSNT |
f405affb | 180 | #define EMACS_KILLPG(gid, signo) (kill (gid, signo)) |
57d65592 | 181 | #else |
9ab9afa9 JB |
182 | #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo))) |
183 | #endif | |
57d65592 | 184 | #endif |
9ab9afa9 JB |
185 | |
186 | /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals | |
187 | testing SIGCHLD. */ | |
9ab9afa9 JB |
188 | #ifndef VMS |
189 | #ifdef SIGCLD | |
190 | #ifndef SIGCHLD | |
191 | #define SIGCHLD SIGCLD | |
985a35a3 JB |
192 | #endif /* SIGCHLD */ |
193 | #endif /* ! defined (SIGCLD) */ | |
194 | #endif /* VMS */ | |
68c45bf0 PE |
195 | |
196 | #ifndef HAVE_STRSIGNAL | |
197 | /* strsignal is in sysdep.c */ | |
198 | char *strsignal (); | |
199 | #endif | |
ab5796a9 MB |
200 | |
201 | /* arch-tag: 4580e86a-340d-4574-9e11-a742b6e1a152 | |
202 | (do not change this comment) */ |