Move everything to i_system.c

This also simplifies things; SDL isn't initialized in the parent process.
This commit is contained in:
James R 2019-12-12 15:07:59 -08:00
parent 2b837726eb
commit 9efe4d8445
4 changed files with 57 additions and 60 deletions

View File

@ -136,10 +136,6 @@
#define LOGMESSAGES // write message in log.txt
#endif
#if (defined (__unix__) && !defined (_MSDOS)) || defined (UNIXCOMMON)
#define NEWSIGNALHANDLER
#endif
#ifdef LOGMESSAGES
extern FILE *logstream;
#endif

View File

@ -92,10 +92,6 @@ ticcmd_t *I_BaseTiccmd4(void);
*/
void I_Quit(void) FUNCNORETURN;
/** \brief Print a message and text box about a signal that was raised.
*/
void I_ReportSignal(int num, int coredumped);
typedef enum
{
EvilForce = -1,

View File

@ -26,11 +26,6 @@
#include <unistd.h>
#endif
#ifdef NEWSIGNALHANDLER
#include <errno.h>
#include <sys/wait.h>
#endif
#ifdef HAVE_SDL
#ifdef HAVE_TTF
@ -163,52 +158,6 @@ int main(int argc, char **argv)
MakeCodeWritable();
#endif
#ifdef NEWSIGNALHANDLER
switch (fork())
{
case -1:
I_Error(
"Error setting up signal reporting: fork(): %s\n",
strerror(errno)
);
break;
case 0:
break;
default:
{
int status;
int signum;
if (wait(&status) == -1)
{
I_Error(
"Error setting up signal reporting: fork(): %s\n",
strerror(errno)
);
}
else
{
if (WIFSIGNALED (status))
{
signum = WTERMSIG (status);
#ifdef WCOREDUMP
I_ReportSignal(signum, WCOREDUMP (status));
#else
I_ReportSignal(signum, 0);
#endif
status = 128 + signum;
}
else if (WIFEXITED (status))
{
status = WEXITSTATUS (status);
}
I_ShutdownSystem();
exit(status);
}
}
}
#endif/*NEWSIGNALHANDLER*/
// startup SRB2
CONS_Printf("Setting up SRB2Kart...\n");
D_SRB2Main();

View File

@ -102,6 +102,12 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#endif
#endif
#if (defined (__unix__) && !defined (_MSDOS)) || defined (UNIXCOMMON)
#include <errno.h>
#include <sys/wait.h>
#define NEWSIGNALHANDLER
#endif
#ifndef NOMUMBLE
#ifdef __linux__ // need -lrt
#include <sys/mman.h>
@ -246,7 +252,7 @@ SDL_bool framebuffer = SDL_FALSE;
UINT8 keyboard_started = false;
void I_ReportSignal(int num, int coredumped)
static void I_ReportSignal(int num, int coredumped)
{
//static char msg[] = "oh no! back to reality!\r\n";
const char * sigmsg;
@ -3043,6 +3049,53 @@ void I_Sleep(void)
SDL_Delay(cv_sleep.value);
}
#ifdef NEWSIGNALHANDLER
static void I_Fork(void)
{
int status;
int signum;
switch (fork())
{
case -1:
I_Error(
"Error setting up signal reporting: fork(): %s\n",
strerror(errno)
);
break;
case 0:
break;
default:
if (wait(&status))
{
I_Error(
"Error setting up signal reporting: fork(): %s\n",
strerror(errno)
);
}
else
{
if (WIFSIGNALED (status))
{
signum = WTERMSIG (status);
#ifdef WCOREDUMP
I_ReportSignal(signum, WCOREDUMP (status));
#else
I_ReportSignal(signum, 0);
#endif
status = 128 + signum;
}
else if (WIFEXITED (status))
{
status = WEXITSTATUS (status);
}
I_ShutdownSystem();
exit(status);
}
}
}
#endif/*NEWSIGNALHANDLER*/
INT32 I_StartupSystem(void)
{
SDL_version SDLcompiled;
@ -3050,6 +3103,9 @@ INT32 I_StartupSystem(void)
SDL_VERSION(&SDLcompiled)
SDL_GetVersion(&SDLlinked);
I_StartupConsole();
#ifdef NEWSIGNALHANDLER
I_Fork();
#endif
I_OutputMsg("Compiled for SDL version: %d.%d.%d\n",
SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch);
I_OutputMsg("Linked with SDL version: %d.%d.%d\n",