Backport of fix from asynchvfs branch for PM-LOG-VFS-PM deadlock that resulted in...
[minix3-old.git] / lib / syslib / panic.c
blob89d3a41ac7c1da5b7da1825cbd4d1b7b4d83f1dd
1 #include <stdlib.h>
2 #include <signal.h>
3 #include <minix/sysutil.h>
5 #include "syslib.h"
7 int panicing= 0;
9 /*===========================================================================*
10 * panic *
11 *===========================================================================*/
12 PUBLIC void panic(who, mess, num)
13 char *who; /* server identification */
14 char *mess; /* message format string */
15 int num; /* number to go with format string */
17 /* Something awful has happened. Panics are caused when an internal
18 * inconsistency is detected, e.g., a programming error or illegal
19 * value of a defined constant.
21 message m;
22 void (*suicide)(void);
24 panicing= 1;
25 if (NULL != who && NULL != mess) {
26 if (num != NO_NUM) {
27 printf("Panic in %s: %s: %d\n", who, mess, num);
28 } else {
29 printf("Panic in %s: %s\n", who, mess);
33 /* Try exit */
34 _exit(1);
36 /* Try to signal ourself */
37 abort();
39 /* If exiting nicely through PM fails for some reason, try to
40 * commit suicide. E.g., message to PM might fail due to deadlock.
42 printf("panic: trying exception\n");
43 suicide = (void (*)(void)) -1;
44 suicide();
46 /* If committing suicide fails for some reason, hang. */
47 printf("panic: for ever and ever\n");
48 for(;;) { }