2 * Subject to the GPL, version 2.
11 void (*on_panic
)(void *arg
);
12 struct panic_handler
*next
;
15 static struct panic_handler
*panic_handlers
;
17 void panic_handler_add(void (*on_panic
)(void *arg
), void *arg
)
19 struct panic_handler
*handler
= xmallocz(sizeof(*handler
));
22 handler
->pid
= getpid();
23 handler
->is_enabled
= true;
24 handler
->on_panic
= on_panic
;
25 handler
->next
= panic_handlers
;
26 panic_handlers
= handler
;
29 void call_panic_handlers(void)
31 struct panic_handler
*it
;
34 for (it
= panic_handlers
; it
; it
= it
->next
) {
35 if (it
->pid
== pid
&& it
->is_enabled
) {
36 it
->is_enabled
= false;
37 it
->on_panic(it
->arg
);