Name:
Anonymous
2012-04-26 15:58
/*
* Non-failing allocation routines (init cannot fail).
*/
static
void *imalloc(size_t size)
{
void *m;
while ((m = malloc(size)) == NULL) {
initlog(L_VB, "out of memory");
do_sleep(5);
}
memset(m, 0, size);
return m;
}
Name:
Anonymous
2012-04-27 15:29
/*
* OOPS: segmentation violation!
* If we have the info, print where it occured.
* Then sleep 30 seconds and try to continue.
*/
static
#if defined(STACK_DEBUG) && defined(__linux__)
# ifdef __GNUC__
void segv_handler(int sig __attribute__((unused)), struct sigcontext ctx)
# else
void segv_handler(int sig, struct sigcontext ctx)
# endif
{
char *p = "";
int saved_errno = errno;
if ((void *)ctx.eip >= (void *)do_sleep &&
(void *)ctx.eip < (void *)main)
p = " (code)";
initlog(L_VB, "PANIC: segmentation violation at %p%s! "
"sleeping for 30 seconds.", (void *)ctx.eip, p);
coredump();
do_sleep(30);
errno = saved_errno;
}
#else
# ifdef __GNUC__
void segv_handler(int sig __attribute__((unused)))
# else
void segv_handler(int sig)
# endif
{
int saved_errno = errno;
initlog(L_VB,
"PANIC: segmentation violation! sleeping for 30 seconds.");
coredump();
do_sleep(30);
errno = saved_errno;
}
#endif