2005-10-17 15:19:22 +02:00
|
|
|
#include <stdlib.h>
|
2006-03-15 13:06:18 +01:00
|
|
|
#include <signal.h>
|
|
|
|
#include <minix/sysutil.h>
|
2005-10-17 15:19:22 +02:00
|
|
|
|
2006-03-15 13:06:18 +01:00
|
|
|
#include "syslib.h"
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-10-24 15:47:24 +02:00
|
|
|
int panicing= 0;
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
2005-06-01 16:31:00 +02:00
|
|
|
* panic *
|
2005-04-21 16:53:53 +02:00
|
|
|
*===========================================================================*/
|
2005-06-01 16:31:00 +02:00
|
|
|
PUBLIC void panic(who, mess, num)
|
2005-04-21 16:53:53 +02:00
|
|
|
char *who; /* server identification */
|
|
|
|
char *mess; /* message format string */
|
|
|
|
int num; /* number to go with format string */
|
|
|
|
{
|
|
|
|
/* Something awful has happened. Panics are caused when an internal
|
|
|
|
* inconsistency is detected, e.g., a programming error or illegal
|
|
|
|
* value of a defined constant.
|
|
|
|
*/
|
|
|
|
message m;
|
2005-10-17 15:19:22 +02:00
|
|
|
void (*suicide)(void);
|
2005-10-24 15:47:24 +02:00
|
|
|
|
|
|
|
panicing= 1;
|
2005-04-21 16:53:53 +02:00
|
|
|
if (NULL != who && NULL != mess) {
|
|
|
|
if (num != NO_NUM) {
|
|
|
|
printf("Panic in %s: %s: %d\n", who, mess, num);
|
|
|
|
} else {
|
|
|
|
printf("Panic in %s: %s\n", who, mess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-23 14:13:51 +02:00
|
|
|
/* Try exit */
|
|
|
|
_exit(1);
|
|
|
|
|
|
|
|
/* Try to signal ourself */
|
|
|
|
abort();
|
|
|
|
|
2005-10-17 15:19:22 +02:00
|
|
|
/* If exiting nicely through PM fails for some reason, try to
|
|
|
|
* commit suicide. E.g., message to PM might fail due to deadlock.
|
|
|
|
*/
|
2007-04-23 14:13:51 +02:00
|
|
|
printf("panic: trying exception\n");
|
2005-10-17 15:19:22 +02:00
|
|
|
suicide = (void (*)(void)) -1;
|
|
|
|
suicide();
|
|
|
|
|
|
|
|
/* If committing suicide fails for some reason, hang. */
|
2007-04-23 14:13:51 +02:00
|
|
|
printf("panic: for ever and ever\n");
|
2005-10-17 15:19:22 +02:00
|
|
|
for(;;) { }
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|