/**
 * TrueReality - os/linux/signal.c
 * Copyright (C) 1998, 1999 Niki W. Waibel
 *
 * This program is free software; you can redistribute it and/
 * or modify it under the terms of the GNU General Public Li-
 * cence as published by the Free Software Foundation; either
 * version 2 of the Licence, or any later version.
 *
 * This program is distributed in the hope that it will be use-
 * ful, but WITHOUT ANY WARRANTY; without even the implied war-
 * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public Licence for more details.
 *
 * You should have received a copy of the GNU General Public
 * Licence along with this program; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
 * USA.
 *
 * Information about me (the author):
 *   Niki W. Waibel, Reichenau 20, 6890 Lustenau, Austria - EUROPE
 *   niki.waibel@gmx.net
**/





/**
 *
 * This file is part of the msdos port and comes from:
 * "Boca Juniors (Diego)" <boca_jrs@hotmail.com>
 *
 * DJGPP and Allegro are needed!
 *
**/
     




#include <signal.h>

#include "../../include/dispatch.h"
#include "../../include/parser_extern.h"

#include "../os.h"
#include "signal.h"





static void Shutdown();
static void Stop();

#if DISPLAY_SUPPORT
        static void VisualKilled();
#endif





void CatchSignals()
{
        signal(SIGINT,  Stop);           /* CTRL+C pressed -> cpu halt -> debugger */
        signal(SIGQUIT, Shutdown);
        signal(SIGTERM, Shutdown);
#if DISPLAY_SUPPORT
        signal(SIGHUP,  VisualKilled);   /* should be sent if display killed */
        signal(SIGPIPE, Shutdown);       /* when pipe is broken */
#endif

} /* void CatchSignals() */





static void Shutdown()
{
        dispatch(SHUTDOWN, 0);

} /* static void Shutdown() */





static void Stop()
{
        signal(SIGINT,  SIG_IGN);
        
        dispatch(CPU_STOP, 0);

        signal(SIGINT,  Stop);           /* CTRL+C pressed -> cpu halt -> debugger */
        
} /* static void Shutdown() */







#if DISPLAY_SUPPORT
static void VisualKilled()
{
        prefs.display = NO_DISPLAY;

} /* void VisualKilled() */
#endif












