f14fb60209
* Updating common/lib * Updating lib/csu * Updating lib/libc * Updating libexec/ld.elf_so * Corrected test on __minix in featuretest to actually follow the meaning of the comment. * Cleaned up _REENTRANT-related defintions. * Disabled -D_REENTRANT for libfetch * Removing some unneeded __NBSD_LIBC defines and tests Change-Id: Ic1394baef74d11b9f86b312f5ff4bbc3cbf72ce2
56 lines
1.3 KiB
C
56 lines
1.3 KiB
C
#include <stdlib.h>
|
|
#include <signal.h>
|
|
#include <unistd.h>
|
|
#include <stdarg.h>
|
|
#include <minix/sysutil.h>
|
|
|
|
#include "syslib.h"
|
|
|
|
/*===========================================================================*
|
|
* panic *
|
|
*===========================================================================*/
|
|
void panic(const char *fmt, ...)
|
|
{
|
|
/* 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.
|
|
*/
|
|
endpoint_t me = NONE;
|
|
char name[20];
|
|
int priv_flags;
|
|
void (*suicide)(void);
|
|
va_list args;
|
|
|
|
if(sys_whoami(&me, name, sizeof(name), &priv_flags) == OK && me != NONE)
|
|
printf("%s(%d): panic: ", name, me);
|
|
else
|
|
printf("(sys_whoami failed): panic: ");
|
|
|
|
if(fmt) {
|
|
va_start(args, fmt);
|
|
vprintf(fmt, args);
|
|
va_end(args);
|
|
} else {
|
|
printf("no message\n");
|
|
}
|
|
printf("\n");
|
|
|
|
printf("syslib:panic.c: stacktrace: ");
|
|
util_stacktrace();
|
|
|
|
/* Try exit */
|
|
_exit(1);
|
|
|
|
/* Try to signal ourself */
|
|
abort();
|
|
|
|
/* If exiting nicely through PM fails for some reason, try to
|
|
* commit suicide. E.g., message to PM might fail due to deadlock.
|
|
*/
|
|
suicide = (void (*)(void)) -1;
|
|
suicide();
|
|
|
|
/* If committing suicide fails for some reason, hang. */
|
|
for(;;) { }
|
|
}
|
|
|