/***************************************************************************
* God Wars Mud originally written by KaVir aka Richard Woolcock. *
* Changes done to the code done by Sage aka Walter Howard, this mud is *
* for the public, however if you run this code it means you agree *
* to the license.low, license.gw, and license.merc have fun. :) *
***************************************************************************/
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <stdarg.h>
#include <unistd.h>
#include <ctype.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include "merc.h"
void do_breakme( CHAR_DATA *ch, char *argument )
{
OBJ_DATA *obj;
crash("Breakme. Good.\n");
obj = create_object( get_obj_index( 9 ), 0 );
return;
}
void crash(char *arg)
{
debug_counter++;
if (debug_counter == 20) debug_counter = 0;
WRITE_STR(debug_procedure[debug_counter], arg);
SS(0);
}
void game_crash( int sig )
{
FILE *fp;
char * fault;
char buf[MAX_INPUT_LENGTH];
DESCRIPTOR_DATA *d, *d_next;
CHAR_DATA *ch;
return;
fault = "none";
switch(sig)
{
case SIGALRM : fault = "Caught Infinite Looping"; break;
case SIGHUP : fault = "SIGHUP"; break;
case SIGSEGV : fault = "Segmentation Fault"; break;
case SIGTERM : fault = "Task Killed"; break;
case SIGINT : fault = "SIGINT"; break;
case SIGQUIT : fault = "SIGQUIT"; break;
case SIGIO : fault = "SIGIO"; break;
case SIGSTOP : fault = "SIGSTOP"; break;
case SIGPIPE : fault = "SIGPIPE"; break;
case SIGABRT : fault = "SIGABRT"; break;
case SIGTRAP : fault = "SIGTRAP"; break;
}
if (!debug_dont_run)
{
debug_dont_run = TRUE;
if ((fp = fopen("crash.details", "a")) != NULL)
{
int i;
fprintf(fp, "*** CRASH DETAILS OF LAST CRASH ***\n\n");
fprintf(fp, "Last command executed was:\n%s\n\nAnd was entered by %s\n\n",
debug_last_command,
debug_last_character);
fprintf(fp, "Command was executed in room: %d\n\n",
debug_last_room);
for (i = 0 ; i < 20 ; i++)
fprintf(fp, "Procedure %d : %s\n", i, debug_procedure[i]);
fprintf(fp, "Last proc written to: %d\n\n", debug_counter);
fprintf(fp, "Crash type : %s\n\n", fault);
fprintf(fp, "Function stage: %d\n\n", debug_stage);
fprintf(fp, "***********************************\n\n");
fclose( fp );
}
for (d = descriptor_list; d != NULL; d = d_next )
{
d_next = d->next;
ch = d->original ? d->original : d->character;
if (ch != NULL && d->connected == CON_PLAYING)
{
int i;
sprintf(buf, "----> Mud crashed - %s - rebooting a.s.a.p. <----\n\r",fault);
stc(buf, ch);
if ( ch->level > 6 )
{
for (i = 0 ; i < 20 ; i++)
{
sprintf(buf, "Procedure number %d was %s.\n\r",
i, debug_procedure[i]);
stc(buf,ch);
}
sprintf(buf, "Last proc written to : %d.\n\r", debug_counter);
stc(buf,ch);
sprintf(buf,"\n\nCommand: %s\n\rPlayer: %s\n\rRoom: %d\n\rBug logged. Do not repeat.\n\r",
debug_last_command,
debug_last_character,
debug_last_room);
stc(buf, ch);
}
close_socket( d );
}
}
}
exit( 1 );
}
void init_signals( void )
{
struct sigaction act;
return;
act.sa_mask = (SIGHUP|SIGSEGV|SIGTERM|SIGALRM|SIGINT|SIGQUIT);
act.sa_flags = SA_RESTART;
act.sa_handler = (*game_crash);
sigaction(SIGHUP, &act, (struct sigaction * ) 0);
sigaction(SIGSEGV, &act, (struct sigaction * ) 0);
sigaction(SIGTERM, &act, (struct sigaction * ) 0);
sigaction(SIGALRM, &act, (struct sigaction * ) 0);
sigaction(SIGINT, &act, (struct sigaction * ) 0);
sigaction(SIGQUIT, &act, (struct sigaction * ) 0);
sigaction(SIGIO, &act, (struct sigaction * ) 0);
sigaction(SIGSTOP, &act, (struct sigaction * ) 0);
sigaction(SIGPIPE, &act, (struct sigaction * ) 0);
sigaction(SIGABRT, &act, (struct sigaction * ) 0);
sigaction(SIGTRAP, &act, (struct sigaction * ) 0);
signal(SIGCHLD, SIG_DFL);
}