remove duplicate const
[AROS.git] / compiler / stdc / raise.c
bloba1a1c34394ce2f0c9c638499ef611d130bf29008
1 /*
2 Copyright © 2009-2012, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "__signal.h"
8 /*****************************************************************************
10 NAME */
11 #include <signal.h>
13 int raise(
15 /* SYNOPSIS */
16 int signum)
18 /* FUNCTION
19 Calls the handler of a signal
21 INPUTS
22 Signal handler to be called.
24 RESULT
25 0: OK
26 -1: error calling handler, errno will be set.
28 NOTES
29 The behaviour of raise() follows the BSD semantics.
30 For each signal the system keeps track of a signal handler is already
31 being called.
32 If not, the signal handler is called; when yes this will logged and the
33 handler will be recalled when the first handler returns. If the a new
34 handler is registered that one will be used then.
36 EXAMPLE
38 BUGS
40 SEE ALSO
42 INTERNALS
44 ******************************************************************************/
46 struct signal_func_data *sigfuncdata = __sig_getfuncdata(signum);
48 if (!sigfuncdata)
49 return -1;
51 /* If a signal handler raises it's own signal then the current
52 signal handler will be called when the first handler completes.
54 sigfuncdata->flags |= __SIG_PENDING;
55 while (!(sigfuncdata->flags & __SIG_RUNNING)
56 && (sigfuncdata->flags & __SIG_PENDING)
59 __sighandler_t *func = sigfuncdata->sigfunc;
60 if (func == SIG_DFL)
61 func = __sig_default;
63 sigfuncdata->flags |= __SIG_RUNNING; /* Signal handler is running ... */
64 sigfuncdata->flags &= ~__SIG_PENDING; /* ... and not pending anymore */
66 if (func != SIG_IGN)
67 func(signum);
69 sigfuncdata->flags &= ~__SIG_RUNNING; /* Signal is not running anymore */
72 return 0;