More signal-handler cleanup.
[bpt/emacs.git] / src / syssignal.h
1 /* syssignal.h - System-dependent definitions for signals.
2
3 Copyright (C) 1993, 1999, 2001-2012 Free Software Foundation, Inc.
4
5 This file is part of GNU Emacs.
6
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include <signal.h>
21
22 extern void init_signals (void);
23
24 #ifdef HAVE_PTHREAD
25 #include <pthread.h>
26 /* If defined, asynchronous signals delivered to a non-main thread are
27 forwarded to the main thread. */
28 #define FORWARD_SIGNAL_TO_MAIN_THREAD
29 #endif
30
31 extern sigset_t empty_mask;
32
33 typedef void (*signal_handler_t) (int);
34
35 extern void emacs_sigaction_init (struct sigaction *, signal_handler_t);
36
37 #if ! (defined TIOCNOTTY || defined USG5 || defined CYGWIN)
38 _Noreturn void croak (char *);
39 #endif
40
41 /* Interrupt input is not used if there is no FIONREAD. */
42 #include <sys/ioctl.h>
43 #if defined BROKEN_SIGIO || ! defined FIONREAD || defined BROKEN_FIONREAD
44 # undef SIGIO
45 #endif
46
47 /* These are only used by AIX */
48 #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
49 #undef SIGPOLL
50 #endif
51 #if defined (SIGAIO) && defined (BROKEN_SIGAIO)
52 #undef SIGAIO
53 #endif
54 #if defined (SIGPTY) && defined (BROKEN_SIGPTY)
55 #undef SIGPTY
56 #endif
57
58 #if NSIG < NSIG_MINIMUM
59 # undef NSIG
60 # define NSIG NSIG_MINIMUM
61 #endif
62
63 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
64 Must do that using the killpg call. */
65 #ifdef BSD_SYSTEM
66 #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
67 #else
68 #ifdef WINDOWSNT
69 #define EMACS_KILLPG(gid, signo) (kill (gid, signo))
70 #else
71 #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
72 #endif
73 #endif
74
75 /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
76 testing SIGCHLD. */
77 #ifdef SIGCLD
78 #ifndef SIGCHLD
79 #define SIGCHLD SIGCLD
80 #endif /* SIGCHLD */
81 #endif /* ! defined (SIGCLD) */
82
83 #ifndef HAVE_STRSIGNAL
84 /* strsignal is in sysdep.c */
85 char *strsignal (int);
86 #endif
87
88 #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
89 extern pthread_t main_thread;
90 #endif
91
92 void handle_on_main_thread (int, signal_handler_t);