d3afa59b877fd2b3b02acae0cef50066e8453a22
4 * A way to set handlers for exceptional conditions (also known as signals).
6 * This file is part of the Mingw32 package.
9 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
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 * DISCLAMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 * $Date: 2002/11/24 18:09:56 $
26 /* added some extra signal constants */
35 * The prototypes (below) are the easy part. The hard part is figuring
36 * out what signals are available and what numbers they are assigned
37 * along with appropriate values of SIG_DFL and SIG_IGN.
41 * A pointer to a signal handler function. A signal handler takes a
42 * single int, which is the signal it handles.
44 typedef void (*_p_sig_fn_t
)(int nSig
);
47 * These are special values of signal handler pointers which are
48 * used to send a signal to the default handler (SIG_DFL), ignore
49 * the signal (SIG_IGN), or indicate an error return (SIG_ERR).
51 #define SIG_DFL ((_p_sig_fn_t) 0)
52 #define SIG_IGN ((_p_sig_fn_t) 1)
53 #define SIG_ERR ((_p_sig_fn_t) -1)
56 * The actual signal values. Using other values with signal
57 * produces a SIG_ERR return value.
59 * NOTE: SIGINT is produced when the user presses Ctrl-C.
60 * SIGILL has not been tested.
61 * SIGFPE doesn't seem to work?
62 * SIGSEGV does not catch writing to a NULL pointer (that shuts down
63 * your app; can you say "segmentation violation core dump"?).
64 * SIGTERM comes from what kind of termination request exactly?
65 * SIGBREAK is indeed produced by pressing Ctrl-Break.
66 * SIGABRT is produced by calling abort.
67 * TODO: The above results may be related to not installing an appropriate
68 * structured exception handling frame. Results may be better if I ever
69 * manage to get the SEH stuff down.
71 #define SIGINT 2 /* Interactive attention */
72 #define SIGILL 4 /* Illegal instruction */
73 #define SIGFPE 8 /* Floating point error */
74 #define SIGSEGV 11 /* Segmentation violation */
75 #define SIGTERM 15 /* Termination request */
76 #define SIGBREAK 21 /* Control-break */
77 #define SIGABRT 22 /* Abnormal termination (abort) */
90 #define SIGTIMR 303 /* Internal for setitimer (SIGALRM, SIGPROF) */
95 * Call signal to set the signal handler for signal sig to the
96 * function pointed to by handler. Returns a pointer to the
97 * previous handler, or SIG_ERR if an error occurs. Initially
98 * unhandled signals defined above will return SIG_DFL.
100 _p_sig_fn_t
signal(int sig
, _p_sig_fn_t func
);
103 * Raise the signal indicated by sig. Returns non-zero on success.