2 Copyright © 2012-2013, The AROS Development Team. All rights reserved.
6 #include <proto/exec.h>
7 #include <proto/intuition.h>
8 #include <libraries/stdc.h>
10 /* We include the signal.h of posixc.library for getting min/max signal number
11 TODO: Implement more elegant way to get maximum and minimum signal number
13 #include <aros/posixc/signal.h>
19 #include "__stdc_intbase.h"
21 #include "__optionallibs.h"
24 #include <aros/debug.h>
26 struct signal_func_data
*__sig_getfuncdata(int signum
)
28 struct StdCIntBase
*StdCBase
=
29 (struct StdCIntBase
*)__aros_getbase_StdCBase();
32 if (signum
< SIGHUP
|| signum
> _SIGMAX
)
38 if (StdCBase
->sigfunc_array
== NULL
)
40 StdCBase
->sigfunc_array
= malloc(_SIGMAX
*sizeof(struct signal_func_data
));
42 if (!StdCBase
->sigfunc_array
)
48 for (i
= 0; i
< _SIGMAX
; i
++)
50 StdCBase
->sigfunc_array
[i
].sigfunc
= SIG_DFL
;
51 StdCBase
->sigfunc_array
[i
].flags
= 0;
55 return &StdCBase
->sigfunc_array
[signum
-1];
58 /* Handler for SIG_DFL */
59 /* TODO: Maybe a mechanism has to be implemented so that default signal handler
60 can be overloaded by libraries. For example by stdcio.library or posixc.library
61 so they can use stdio for presenting the caught signal
63 void __sig_default(int signum
)
66 char *taskname
= FindTask(NULL
)->tc_Node
.ln_Name
;
71 sprintf(s
, "Program '%s' aborted.", taskname
);
75 sprintf(s
, "Program '%s' terminated.", taskname
);
79 sprintf(s
, "Program '%s' caught signal %d\naborting...",
85 /* Open requester if IntuitionBase is available otherwise use kprintf() */
86 if (__intuition_available())
88 struct EasyStruct es
=
90 sizeof(struct EasyStruct
),
97 EasyRequest(NULL
, &es
, NULL
, s
);
102 __stdc_jmp2exit(0, 20);
104 assert(0); /* Should not be reached */