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