]> code.delx.au - gnu-emacs/blob - src/syssignal.h
(EMACS_KILLPG) [WINDOWSNT]: Invoke kill instead of win32_kill_process.
[gnu-emacs] / src / syssignal.h
1 /* syssignal.h - System-dependent definitions for signals.
2 Copyright (C) 1993 Free Software Foundation, Inc.
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
8 the Free Software Foundation; either version 2, or (at your option)
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
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 #ifdef POSIX_SIGNALS
22
23 /* Don't #include <signal.h>. That header should always be #included
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. */
28
29 #define SIGMASKTYPE sigset_t
30
31 #define SIGEMPTYMASK (empty_mask)
32 #define SIGFULLMASK (full_mask)
33 extern sigset_t empty_mask, full_mask, temp_mask;
34
35 /* POSIX pretty much destroys any possibility of writing sigmask as a
36 macro in standard C. */
37 #ifndef sigmask
38 #ifdef __GNUC__
39 #define sigmask(SIG) \
40 ({ \
41 sigset_t _mask; \
42 sigemptyset (&_mask); \
43 sigaddset (&_mask, SIG); \
44 _mask; \
45 })
46 #else /* ! defined (__GNUC__) */
47 extern sigset_t sys_sigmask ();
48 #define sigmask(SIG) (sys_sigmask (SIG))
49 #endif /* ! defined (__GNUC__) */
50 #endif
51
52 #define sigpause(SIG) sys_sigpause (SIG)
53 #define sigblock(SIG) sys_sigblock (SIG)
54 #define sigunblock(SIG) sys_sigunblock (SIG)
55 #ifndef sigsetmask
56 #define sigsetmask(SIG) sys_sigsetmask (SIG)
57 #endif
58 #define sighold(SIG) ONLY_USED_IN_BSD_4_1
59 #define sigrelse(SIG) ONLY_USED_IN_BSD_4_1
60 #undef signal
61 #define signal(SIG,ACT) sys_signal(SIG,ACT)
62
63 /* Whether this is what all systems want or not, this is what
64 appears to be assumed in the source, for example data.c:arith_error. */
65 typedef RETSIGTYPE (*signal_handler_t) (/*int*/);
66
67 signal_handler_t sys_signal (/*int signal_number, signal_handler_t action*/);
68 int sys_sigpause (/*sigset_t new_mask*/);
69 sigset_t sys_sigblock (/*sigset_t new_mask*/);
70 sigset_t sys_sigunblock (/*sigset_t new_mask*/);
71 sigset_t sys_sigsetmask (/*sigset_t new_mask*/);
72
73 #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
74
75 #else /* ! defined (POSIX_SIGNALS) */
76 #ifdef USG5_4
77
78 #ifndef sigblock
79 #define sigblock(sig) (sigprocmask (SIG_BLOCK, SIGEMPTYMASK | sig, NULL))
80 #endif
81
82 #define sigunblock(sig) (sigprocmask (SIG_SETMASK, SIGFULLMASK & ~(sig), NULL))
83
84 #else
85 #ifdef USG
86
87 #define sigunblock(sig)
88
89 #else
90
91 #define sigunblock(SIG) \
92 { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
93
94 #endif /* ! defined (USG) */
95 #endif /* ! defined (USG5_4) */
96 #endif /* ! defined (POSIX_SIGNALS) */
97
98 #ifndef SIGMASKTYPE
99 #define SIGMASKTYPE int
100 #endif
101
102 #ifndef SIGEMPTYMASK
103 #define SIGEMPTYMASK (0)
104 #endif
105
106 #ifndef SIGFULLMASK
107 #define SIGFULLMASK (0xffffffff)
108 #endif
109
110 #ifndef sigmask
111 #define sigmask(no) (1L << ((no) - 1))
112 #endif
113
114 #ifndef sigunblock
115 #define sigunblock(SIG) \
116 { SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
117 #endif
118
119 /* It would be very nice if we could somehow clean up all this trash. */
120
121 #ifndef BSD4_1
122 #define sigfree() sigsetmask (SIGEMPTYMASK)
123 #define sigholdx(sig) sigsetmask (sigmask (sig))
124 #define sigblockx(sig) sigblock (sigmask (sig))
125 #define sigunblockx(sig) sigblock (SIGEMPTYMASK)
126 #define sigpausex(sig) sigpause (0)
127 #endif /* BSD4_1 */
128
129 #ifdef BSD4_1
130 #define SIGIO SIGTINT
131 /* sigfree and sigholdx are in sysdep.c */
132 #define sigblockx(sig) sighold (sig)
133 #define sigunblockx(sig) sigrelse (sig)
134 #define sigpausex(sig) sigpause (sig)
135 #endif /* ! defined (BSD4_1) */
136
137 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
138 Must do that using the killpg call. */
139 #ifdef BSD
140 #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
141 #else
142 #ifdef WINDOWSNT
143 #define EMACS_KILLPG(gid, signo) (kill (gid, signo))
144 #else
145 #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
146 #endif
147 #endif
148
149 /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
150 testing SIGCHLD. */
151 #ifndef VMS
152 #ifdef SIGCLD
153 #ifndef SIGCHLD
154 #define SIGCHLD SIGCLD
155 #endif /* SIGCHLD */
156 #endif /* ! defined (SIGCLD) */
157 #endif /* VMS */