branch update for HEAD-2003021201
[reactos.git] / include / msvcrt / signal.h
1 /* 
2  * signal.h
3  *
4  * A way to set handlers for exceptional conditions (also known as signals).
5  *
6  * This file is part of the Mingw32 package.
7  *
8  * Contributors:
9  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
10  *
11  *  THIS SOFTWARE IS NOT COPYRIGHTED
12  *
13  *  This source code is offered for use in the public domain. You may
14  *  use, modify or distribute it freely.
15  *
16  *  This code is distributed in the hope that it will be useful but
17  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18  *  DISCLAIMED. This includes but is not limited to warranties of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * $Revision$
22  * $Author$
23  * $Date$
24  *
25  */
26 /* added some extra signal constants */
27 #ifndef _SIGNAL_H_
28 #define _SIGNAL_H_
29
30
31 /*
32  * The actual signal values. Using other values with signal
33  * produces a SIG_ERR return value.
34  *
35  * NOTE: SIGINT is produced when the user presses Ctrl-C.
36  *       SIGILL has not been tested.
37  *       SIGFPE doesn't seem to work?
38  *       SIGSEGV does not catch writing to a NULL pointer (that shuts down
39  *               your app; can you say "segmentation violation core dump"?).
40  *       SIGTERM comes from what kind of termination request exactly?
41  *       SIGBREAK is indeed produced by pressing Ctrl-Break.
42  *       SIGABRT is produced by calling abort.
43  * TODO: The above results may be related to not installing an appropriate
44  *       structured exception handling frame. Results may be better if I ever
45  *       manage to get the SEH stuff down.
46  */
47 #define SIGINT      2   /* Interactive attention */
48 #define SIGILL      4   /* Illegal instruction */
49 #define SIGFPE      8   /* Floating point error */
50 #define SIGSEGV     11  /* Segmentation violation */
51 #define SIGTERM     15  /* Termination request */
52 #define SIGBREAK    21  /* Control-break */
53 #define SIGABRT     22  /* Abnormal termination (abort) */
54
55 #define SIGALRM 293
56 #define SIGHUP  294
57 /* SIGINT is ansi */
58 #define SIGKILL 296
59 #define SIGPIPE 297
60 #define SIGQUIT 298
61 #define SIGUSR1 299
62 #define SIGUSR2 300
63
64 #define SIGNOFP 301
65 #define SIGTRAP 302
66 #define SIGTIMR 303 /* Internal for setitimer (SIGALRM, SIGPROF) */
67 #define SIGPROF 304
68 #define SIGMAX  320
69
70 /*
71  * The prototypes (below) are the easy part. The hard part is figuring
72  * out what signals are available and what numbers they are assigned
73  * along with appropriate values of SIG_DFL and SIG_IGN.
74  */
75
76 /*
77  * A pointer to a signal handler function. A signal handler takes a
78  * single int, which is the signal it handles.
79  */
80 typedef void (*_p_sig_fn_t)(int);
81
82 /*
83  * These are special values of signal handler pointers which are
84  * used to send a signal to the default handler (SIG_DFL), ignore
85  * the signal (SIG_IGN), or indicate an error return (SIG_ERR).
86  */
87 #define SIG_DFL ((_p_sig_fn_t) 0)
88 #define SIG_IGN ((_p_sig_fn_t) 1)
89 #define SIG_ERR ((_p_sig_fn_t) -1)
90
91 #ifdef  __cplusplus
92 extern "C" {
93 #endif
94
95
96 /*
97  * Call signal to set the signal handler for signal sig to the
98  * function pointed to by handler. Returns a pointer to the
99  * previous handler, or SIG_ERR if an error occurs. Initially
100  * unhandled signals defined above will return SIG_DFL.
101  */
102 _p_sig_fn_t signal(int sig, _p_sig_fn_t func);
103
104 /*
105  * Raise the signal indicated by sig. Returns non-zero on success.
106  */
107 int raise(int);
108
109 #ifdef  __cplusplus
110 }
111 #endif
112
113 #endif  /* Not _SIGNAL_H_ */