Typedefs | Functions | Variables
ui-signals.c File Reference

Handle various OS signals. More...

#include "angband.h"
#include "game-world.h"
#include "savefile.h"
#include "ui-game.h"
#include "ui-signals.h"
#include "ui-term.h"
#include <signal.h>
#include <sys/types.h>


typedef void(* Signal_Handler_t) (int)


static Signal_Handler_t wrap_signal (int sig, Signal_Handler_t handler)
 Wrapper around signal() which it is safe to take the address of, in case signal itself is hidden by some some macro magic. More...
static void handle_signal_suspend (int sig)
 Handle signals – suspend. More...
static void handle_signal_simple (int sig)
 Handle signals – simple (interrupt and quit) More...
static void handle_signal_abort (int sig)
 Handle signal – abort, kill, etc. More...
void signals_ignore_tstp (void)
 Ignore SIGTSTP signals (keyboard suspend) More...
void signals_handle_tstp (void)
 Handle SIGTSTP signals (keyboard suspend) More...
void signals_init (void)
 Prepare to handle the relevant signals. More...


s16b signal_count
static Signal_Handler_t(* signal_aux )(int, Signal_Handler_t) = wrap_signal

Detailed Description

Handle various OS signals.

Copyright (c) 1997 Ben Harrison

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Typedef Documentation

◆ Signal_Handler_t

typedef void(* Signal_Handler_t) (int)

Function Documentation

◆ handle_signal_abort()

static void handle_signal_abort ( int  sig)

◆ handle_signal_simple()

static void handle_signal_simple ( int  sig)

Handle signals – simple (interrupt and quit)

This function was causing a huge number of problems, so it has been simplified greatly. We keep a global variable which counts the number of times the user attempts to kill the process, and we commit suicide if the user does this a certain number of times.

We attempt to give "feedback" to the user as he approaches the suicide thresh-hold, but without penalizing accidental keypresses.

To prevent messy accidents, we should reset this global variable whenever the user enters a keypress, or something like that.

References character_generated, character_saved, close_game(), COLOUR_WHITE, player::died_from, player::is_dead, my_strcpy(), player_upkeep::playing, quit(), signal_aux, signal_count, Term_erase(), Term_fresh(), Term_putstr(), Term_xtra(), TERM_XTRA_NOISE, player::upkeep, and void().

Referenced by signals_init().

◆ handle_signal_suspend()

static void handle_signal_suspend ( int  sig)

Handle signals – suspend.

Actually suspend the game, and then resume cleanly

References signal_aux, Term_fresh(), Term_redraw(), Term_xtra(), TERM_XTRA_ALIVE, and void().

Referenced by signals_handle_tstp(), and signals_init().

◆ signals_handle_tstp()

void signals_handle_tstp ( void  )

Handle SIGTSTP signals (keyboard suspend)

References handle_signal_suspend(), signal_aux, and void().

Referenced by close_game(), save_game(), and signals_init().

◆ signals_ignore_tstp()

void signals_ignore_tstp ( void  )

Ignore SIGTSTP signals (keyboard suspend)

References signal_aux, and void().

Referenced by close_game(), handle_signal_abort(), save_game(), and signals_init().

◆ signals_init()

void signals_init ( void  )

Prepare to handle the relevant signals.

SIGDANGER: This is not a common (POSIX, SYSV, BSD) signal, it is used by AIX(?) to signal that the system will soon be out of memory.

References handle_signal_abort(), handle_signal_simple(), handle_signal_suspend(), signal_aux, signals_handle_tstp(), signals_ignore_tstp(), signals_init(), and void().

Referenced by main(), and signals_init().

◆ wrap_signal()

static Signal_Handler_t wrap_signal ( int  sig,
Signal_Handler_t  handler 

Wrapper around signal() which it is safe to take the address of, in case signal itself is hidden by some some macro magic.

Variable Documentation

◆ signal_aux

Signal_Handler_t(* signal_aux) (int, Signal_Handler_t) = wrap_signal

◆ signal_count

s16b signal_count

Referenced by handle_signal_simple(), and inkey_ex().