2 Copyright © 2012-2018, The AROS Development Team. All rights reserved.
6 #include <proto/exec.h>
10 #include <libraries/stdc.h>
12 /* We include the signal.h of posixc.library for getting min/max signal number
13 TODO: Implement more elegant way to get maximum and minimum signal number
15 #include <aros/posixc/signal.h>
21 #include "__stdc_intbase.h"
23 #include "__optionallibs.h"
26 #include <aros/debug.h>
28 struct signal_func_data
*__sig_getfuncdata(int signum
)
30 struct StdCIntBase
*StdCBase
=
31 (struct StdCIntBase
*)__aros_getbase_StdCBase();
34 if (signum
< SIGHUP
|| signum
> _SIGMAX
)
40 if (StdCBase
->sigfunc_array
== NULL
)
42 StdCBase
->sigfunc_array
= malloc(_SIGMAX
*sizeof(struct signal_func_data
));
44 if (!StdCBase
->sigfunc_array
)
50 for (i
= 0; i
< _SIGMAX
; i
++)
52 StdCBase
->sigfunc_array
[i
].sigfunc
= SIG_DFL
;
53 StdCBase
->sigfunc_array
[i
].flags
= 0;
57 return &StdCBase
->sigfunc_array
[signum
-1];
60 /* Handler for SIG_DFL */
61 /* TODO: Maybe a mechanism has to be implemented so that default signal handler
62 can be overloaded by libraries. For example by stdcio.library or posixc.library
63 so they can use stdio for presenting the caught signal
65 void __sig_default(int signum
)
67 struct StdCIntBase
*StdCBase
=
68 (struct StdCIntBase
*)__aros_getbase_StdCBase();
69 char *taskname
= FindTask(NULL
)->tc_Node
.ln_Name
;
75 sprintf(s
, "Program '%s' aborted.", taskname
);
79 sprintf(s
, "Program '%s' terminated.", taskname
);
83 sprintf(s
, "Program '%s' caught signal %d\naborting...",
89 /* Open requester if IntuitionBase is available otherwise use kprintf() */
90 if (__intuition_available(StdCBase
))
92 struct EasyStruct es
=
94 sizeof(struct EasyStruct
),
100 stdcEasyRequest(StdCBase
->StdCIntuitionBase
, NULL
, &es
, NULL
, s
);
105 __stdc_jmp2exit(0, 20);
107 assert(0); /* Should not be reached */