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 #if defined (SIGIO) && defined (BROKEN_SIGIO)
42 # undef SIGIO
43 #endif
44 /* These are only used by AIX */
45 #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
46 #undef SIGPOLL
47 #endif
48 #if defined (SIGAIO) && defined (BROKEN_SIGAIO)
49 #undef SIGAIO
50 #endif
51 #if defined (SIGPTY) && defined (BROKEN_SIGPTY)
52 #undef SIGPTY
53 #endif
54
55 #if NSIG < NSIG_MINIMUM
56 # undef NSIG
57 # define NSIG NSIG_MINIMUM
58 #endif
59
60 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
61 Must do that using the killpg call. */
62 #ifdef BSD_SYSTEM
63 #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
64 #else
65 #ifdef WINDOWSNT
66 #define EMACS_KILLPG(gid, signo) (kill (gid, signo))
67 #else
68 #define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
69 #endif
70 #endif
71
72 /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
73 testing SIGCHLD. */
74 #ifdef SIGCLD
75 #ifndef SIGCHLD
76 #define SIGCHLD SIGCLD
77 #endif /* SIGCHLD */
78 #endif /* ! defined (SIGCLD) */
79
80 #ifndef HAVE_STRSIGNAL
81 /* strsignal is in sysdep.c */
82 char *strsignal (int);
83 #endif
84
85 #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
86 extern pthread_t main_thread;
87 void handle_on_main_thread (int, signal_handler_t);
88 #endif