source: trunk/minix/lib/syslib/panic.c@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.2 KB
Line 
1#include <stdlib.h>
2#include <signal.h>
3#include <minix/sysutil.h>
4
5#include "syslib.h"
6
7int panicing= 0;
8
9/*===========================================================================*
10 * panic *
11 *===========================================================================*/
12PUBLIC void panic(who, mess, num)
13char *who; /* server identification */
14char *mess; /* message format string */
15int num; /* number to go with format string */
16{
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.
20 */
21 message m;
22 void (*suicide)(void);
23
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);
30 }
31 }
32
33 /* Try to signal ourself */
34 sys_kill(SELF, SIGKILL);
35
36 /* If exiting nicely through PM fails for some reason, try to
37 * commit suicide. E.g., message to PM might fail due to deadlock.
38 */
39 suicide = (void (*)(void)) -1;
40 suicide();
41
42 /* If committing suicide fails for some reason, hang. */
43 for(;;) { }
44}
45
Note: See TracBrowser for help on using the repository browser.