comparison src/syssignal.h @ 613:023b83f4e54b

[xemacs-hg @ 2001-06-10 10:42:16 by ben] ------ signal-code changes ------ data.c, device-tty.c, emacs.c, floatfns.c, linuxplay.c, nas.c, process-unix.c, signal.c, sunplay.c, sysdep.c, syssignal.h: use EMACS_SIGNAL everywhere instead of playing preprocessing games with signal(). s\windowsnt.h, s\mingw32.h, syssignal.h: Remove mswindows signal code from s+m headers and move to syssignal.h as one of the five ways of signal handling, instead of playing preprocessing games. fileio.c, sysdep.c: Rename sys_do_signal to qxe_reliable_signal. signal.c, process-unix.c, profile.c: Create set_timeout_signal(); use instead of just EMACS_SIGNAL to establish a signal handler on a timeout signal; this does special things under Cygwin. nt.c: Eliminate term_ntproc(), which is blank; used as a SIGABRT handler, which was wrong anyway. nt.c, win32.c: Move signal code from nt.c to win32.c, since Cygwin needs it too when dealing with timeout signals. s\cygwin32.h: Define CYGWIN_BROKEN_SIGNALS. ------ other changes ------ s\mingw32.h: Fix problems with NOT_C_CODE being in the wrong place and excluding defines needed when building Makefile.in.in. filelock.c, mule-canna.c, mule-ccl.c, mule-ccl.h, ralloc.c, unexalpha.c, unexapollo.c, unexcw.c, unexelfsgi.c, unexnt.c, unexsni.c, s\aix3-1.h, s\bsd4-1.h, s\bsd4-2.h, s\bsd4-3.h, s\cxux.h, s\cygwin32.h, s\dgux.h, s\dgux5-4r2.h, s\dgux5-4r3.h, s\dgux5-4r4.h, s\ewsux5r4.h, s\gnu.h, s\hpux.h, s\iris3-5.h, s\iris3-6.h, s\irix3-3.h, s\linux.h, s\mingw32.h, s\newsos5.h, s\nextstep.h, s\ptx.h, s\riscix1-1.h, s\riscix1-2.h, s\rtu.h, s\sco4.h, s\sco5.h, s\template.h, s\ultrix.h, s\umax.h, s\umips.h, s\unipl5-0.h, s\unipl5-2.h, s\usg5-0.h, s\usg5-2-2.h, s\usg5-2.h, s\usg5-3.h, s\usg5-4.h, s\windowsnt.h, s\xenix.h: Rename 'GNU Emacs' to XEmacs in the copyright and comments. nas.c: Stylistic cleanup. Avoid preprocessing games with names such as play_sound_file. ------ signal-code changes ------ data.c, device-tty.c, emacs.c, floatfns.c, linuxplay.c, nas.c, process-unix.c, signal.c, sunplay.c, sysdep.c, syssignal.h: use EMACS_SIGNAL everywhere instead of playing preprocessing games with signal(). s\windowsnt.h, s\mingw32.h, syssignal.h: Remove mswindows signal code from s+m headers and move to syssignal.h as one of the five ways of signal handling, instead of playing preprocessing games. fileio.c, sysdep.c: Rename sys_do_signal to qxe_reliable_signal. signal.c, process-unix.c, profile.c: Create set_timeout_signal(); use instead of just EMACS_SIGNAL to establish a signal handler on a timeout signal; this does special things under Cygwin. nt.c: Eliminate term_ntproc(), which is blank; used as a SIGABRT handler, which was wrong anyway. nt.c, win32.c: Move signal code from nt.c to win32.c, since Cygwin needs it too when dealing with timeout signals. s\cygwin32.h: Define CYGWIN_BROKEN_SIGNALS. ------ other changes ------ s\mingw32.h: Fix problems with NOT_C_CODE being in the wrong place and excluding defines needed when building Makefile.in.in. filelock.c, mule-canna.c, mule-ccl.c, mule-ccl.h, ralloc.c, unexalpha.c, unexapollo.c, unexcw.c, unexelfsgi.c, unexnt.c, unexsni.c, s\aix3-1.h, s\bsd4-1.h, s\bsd4-2.h, s\bsd4-3.h, s\cxux.h, s\cygwin32.h, s\dgux.h, s\dgux5-4r2.h, s\dgux5-4r3.h, s\dgux5-4r4.h, s\ewsux5r4.h, s\gnu.h, s\hpux.h, s\iris3-5.h, s\iris3-6.h, s\irix3-3.h, s\linux.h, s\mingw32.h, s\newsos5.h, s\nextstep.h, s\ptx.h, s\riscix1-1.h, s\riscix1-2.h, s\rtu.h, s\sco4.h, s\sco5.h, s\template.h, s\ultrix.h, s\umax.h, s\umips.h, s\unipl5-0.h, s\unipl5-2.h, s\usg5-0.h, s\usg5-2-2.h, s\usg5-2.h, s\usg5-3.h, s\usg5-4.h, s\windowsnt.h, s\xenix.h: Rename 'GNU Emacs' to XEmacs in the copyright and comments. nas.c: Stylistic cleanup. Avoid preprocessing games with names such as play_sound_file. xemacs-faq.texi: Update sections on Windows and MacOS availability. alist.el, apropos.el, autoload.el, bytecomp.el, cl-compat.el, cl-extra.el, cl-macs.el, cl-seq.el, cl.el, cmdloop.el, cus-edit.el, derived.el, gpm.el, itimer.el, lisp-mode.el, shadow.el, version.el, wid-browse.el: Rename 'GNU Emacs' to XEmacs in the copyright. Fix other references to GNU Emacs that should be XEmacs or just Emacs. files.el: Fix warning. simple.el: transpose-line-up/down will now move the region up or down by a line if active. cvtmail.c, fakemail.c, gnuserv.c, gnuserv.h, gnuslib.c, make-msgfile.c, make-path.c, pop.c, pop.h, profile.c, tcp.c: Rename 'GNU Emacs' to XEmacs in the copyright. Fix comments in similar ways. digest-doc.c, sorted-doc.c: Fix program and author name to reflect XEmacs.
author ben
date Sun, 10 Jun 2001 10:42:39 +0000
parents abe6d1db359e
children 943eaba38521
comparison
equal deleted inserted replaced
612:ff0d9e7facba 613:023b83f4e54b
87 87
88 Note that on some systems, more than one paradigm is implemented 88 Note that on some systems, more than one paradigm is implemented
89 (typically, the POSIX sigaction/sigprocmask and either the older 89 (typically, the POSIX sigaction/sigprocmask and either the older
90 SYSV or BSD way). In such a case, we prefer the POSIX way. 90 SYSV or BSD way). In such a case, we prefer the POSIX way.
91 91
92 NOTE: We use EMACS_* macros for most signal operations, but 92 We used to say this:
93
94 [[ NOTE: We use EMACS_* macros for most signal operations, but
93 just signal() for the standard signal-setting operation. 95 just signal() for the standard signal-setting operation.
94 Perhaps we should change this to EMACS_SIGNAL(), but that runs 96 Perhaps we should change this to EMACS_SIGNAL(), but that runs
95 the risk of someone forgetting this convention and calling 97 the risk of someone forgetting this convention and calling
96 signal() directly. */ 98 signal() directly. ]]
99
100 But current policy is to avoid playing with macros as much as
101 possible, since in the long run it really just ends up creating
102 unmaintainable code -- someone newly reading the code is never
103 going to realize exactly which calls are redirected, and on
104 which systems, and where the redirection occurs.
105
106 Possibly we should use the new "qxe" convention.
107 */
97 108
98 #ifndef NeXT 109 #ifndef NeXT
99 typedef SIGTYPE (*signal_handler_t) (int); 110 typedef SIGTYPE (*signal_handler_t) (int);
100 #endif 111 #endif
101 112
102 #if defined (HAVE_SIGPROCMASK) 113 #if defined (HAVE_SIGPROCMASK)
103 114
104 /* The POSIX way (sigaction, sigprocmask, sigpending, sigsuspend) */ 115 /* The POSIX way (sigaction, sigprocmask, sigpending, sigsuspend) */
105 116
106 signal_handler_t sys_do_signal (int signal_number, signal_handler_t action); 117 signal_handler_t qxe_reliable_signal (int signal_number,
107 /* Provide our own version of signal(), that calls sigaction(). The 118 signal_handler_t action);
108 name is not sys_signal() because a function of that name exists in 119
109 libenergize.a */ 120 #define EMACS_SIGNAL qxe_reliable_signal
110 #undef signal
111 #define signal sys_do_signal
112 121
113 #define EMACS_BLOCK_SIGNAL(sig) do \ 122 #define EMACS_BLOCK_SIGNAL(sig) do \
114 { \ 123 { \
115 sigset_t ES_mask; \ 124 sigset_t ES_mask; \
116 sigemptyset (&ES_mask); \ 125 sigemptyset (&ES_mask); \
145 154
146 /* It's OK to use signal() here directly. No unreliable signal 155 /* It's OK to use signal() here directly. No unreliable signal
147 problems. However, we use sigvec() because it allows us to 156 problems. However, we use sigvec() because it allows us to
148 request interruptible I/O. */ 157 request interruptible I/O. */
149 158
150 #define signal sys_do_signal 159 #define EMACS_SIGNAL qxe_reliable_signal
151 160
152 /* Is it necessary to define sigmask like this? */ 161 /* Is it necessary to define sigmask like this? */
153 #ifndef sigmask 162 #ifndef sigmask
154 # define sigmask(no) (1L << ((no) - 1)) 163 # define sigmask(no) (1L << ((no) - 1))
155 #endif 164 #endif
167 #elif defined (HAVE_SIGHOLD) 176 #elif defined (HAVE_SIGHOLD)
168 177
169 /* The older SYSV way (signal/sigset, sighold, sigrelse, sigignore, 178 /* The older SYSV way (signal/sigset, sighold, sigrelse, sigignore,
170 sigpause) */ 179 sigpause) */
171 180
172 #define signal sigset 181 #define EMACS_SIGNAL sigset
173 #define EMACS_BLOCK_SIGNAL(sig) sighold (sig) 182 #define EMACS_BLOCK_SIGNAL(sig) sighold (sig)
174 #define EMACS_UNBLOCK_SIGNAL(sig) sigrelse (sig) 183 #define EMACS_UNBLOCK_SIGNAL(sig) sigrelse (sig)
175 /* #### There's not really any simple way to implement this. 184 /* #### There's not really any simple way to implement this.
176 Since EMACS_UNBLOCK_ALL_SIGNALS() is only called once (at startup), 185 Since EMACS_UNBLOCK_ALL_SIGNALS() is only called once (at startup),
177 it's probably OK to just ignore it. */ 186 it's probably OK to just ignore it. */
178 #define EMACS_UNBLOCK_ALL_SIGNALS() 0 187 #define EMACS_UNBLOCK_ALL_SIGNALS() 0
179 #define EMACS_WAIT_FOR_SIGNAL(sig) sigpause (sig) 188 #define EMACS_WAIT_FOR_SIGNAL(sig) sigpause (sig)
180 #define EMACS_REESTABLISH_SIGNAL(sig, handler) 189 #define EMACS_REESTABLISH_SIGNAL(sig, handler)
181 190
191 #elif defined (WIN32_NATIVE)
192
193 /* MS Windows signal emulation (in turns emulates the sigset/sighold
194 paradigm) */
195
196 #define EMACS_SIGNAL mswindows_sigset
197 #define EMACS_BLOCK_SIGNAL(sig) mswindows_sighold (sig)
198 #define EMACS_UNBLOCK_SIGNAL(sig) mswindows_sigrelse (sig)
199 /* #### There's not really any simple way to implement this.
200 Since EMACS_UNBLOCK_ALL_SIGNALS() is only called once (at startup),
201 it's probably OK to just ignore it. */
202 #define EMACS_UNBLOCK_ALL_SIGNALS() 0
203 #define EMACS_WAIT_FOR_SIGNAL(sig) mswindows_sigpause (sig)
204 #define EMACS_REESTABLISH_SIGNAL(sig, handler)
205
206 /* Defines that we need that aren't in the standard signal.h */
207 #define SIGHUP 1 /* Hang up */
208 #define SIGQUIT 3 /* Quit process */
209 #define SIGKILL 9 /* Die, die die */
210 #define SIGALRM 14 /* Alarm */
211 #define SIGPROF 29 /* Profiling timer exp */
212
182 #else 213 #else
183 214
184 /* The oldest SYSV way (signal only; unreliable signals) */ 215 /* The oldest SYSV way (signal only; unreliable signals) */
185 216
186 /* Old USG systems don't really have signal blocking. 217 /* Old USG systems don't really have signal blocking.
187 We indicate this by not defining EMACS_BLOCK_SIGNAL or 218 We indicate this by not defining EMACS_BLOCK_SIGNAL or
188 EMACS_WAIT_FOR_SIGNAL. */ 219 EMACS_WAIT_FOR_SIGNAL. */
220 #define EMACS_SIGNAL signal
189 #define EMACS_UNBLOCK_SIGNAL(sig) 0 221 #define EMACS_UNBLOCK_SIGNAL(sig) 0
190 #define EMACS_UNBLOCK_ALL_SIGNALS() 0 222 #define EMACS_UNBLOCK_ALL_SIGNALS() 0
191 #define EMACS_REESTABLISH_SIGNAL(sig, handler) do \ 223 #define EMACS_REESTABLISH_SIGNAL(sig, handler) do \
192 { \ 224 { \
193 int old_errno = errno; \ 225 int old_errno = errno; \
203 it will get called again, infinitely. We only need to 235 it will get called again, infinitely. We only need to
204 worry about this on systems where signals need to be 236 worry about this on systems where signals need to be
205 reestablished (SYSV Release 2 and earlier). */ 237 reestablished (SYSV Release 2 and earlier). */
206 #define OBNOXIOUS_SYSV_SIGCLD_BEHAVIOR 238 #define OBNOXIOUS_SYSV_SIGCLD_BEHAVIOR
207 239
208 #endif 240 #endif /* different signalling methods */
209 241
210 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp. 242 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
211 Must do that using the killpg call. */ 243 Must do that using the killpg call. */
212 #ifdef HAVE_KILLPG 244 #ifdef HAVE_KILLPG
213 #define EMACS_KILLPG(pid, signo) killpg (pid, signo) 245 #define EMACS_KILLPG(pid, signo) killpg (pid, signo)
232 264
233 #ifdef SIGDANGER 265 #ifdef SIGDANGER
234 SIGTYPE memory_warning_signal (int sig); 266 SIGTYPE memory_warning_signal (int sig);
235 #endif 267 #endif
236 268
237 #ifdef WIN32_NATIVE 269 #if defined (WIN32_NATIVE) || defined (CYGWIN_BROKEN_SIGNALS)
238 /* Prototypes for signal functions, see nt.c */
239 typedef void (__cdecl *mswindows_sighandler) (int); 270 typedef void (__cdecl *mswindows_sighandler) (int);
240 mswindows_sighandler mswindows_sigset (int sig, mswindows_sighandler handler); 271
272 /* Prototypes for signal functions, see win32.c */
241 int mswindows_sighold (int nsig); 273 int mswindows_sighold (int nsig);
242 int mswindows_sigrelse (int nsig); 274 int mswindows_sigrelse (int nsig);
243 int mswindows_sigpause (int nsig); 275 int mswindows_sigpause (int nsig);
244 int mswindows_raise (int nsig); 276 int mswindows_raise (int nsig);
245 #endif /* WIN32_NATIVE */ 277 mswindows_sighandler mswindows_sigset (int sig, mswindows_sighandler handler);
278
279 #endif /* defined (WIN32_NATIVE) || defined (CYGWIN_BROKEN_SIGNALS) */
280
281 signal_handler_t set_timeout_signal (int signal_number,
282 signal_handler_t action);
283
246 284
247 #endif /* INCLUDED_syssignal_h_ */ 285 #endif /* INCLUDED_syssignal_h_ */