mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-19 16:00:56 +00:00
Add an signal handler for SIGINT and SIGTERM
This allows the user to shut the client down by pressing ctrl-c in it's terminal or by sendig SIGTERM.
This commit is contained in:
parent
ab220c10d6
commit
be14aea08d
1 changed files with 13 additions and 1 deletions
|
@ -20,7 +20,8 @@
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*
|
*
|
||||||
* This is a signal handler for printing some hints to debug problem in
|
* This is a signal handler for printing some hints to debug problem in
|
||||||
* the case of a crash. On Linux a backtrace is printed.
|
* the case of a crash. On Linux a backtrace is printed. Additionally
|
||||||
|
* a special handler for SIGINT and SIGTERM ist supplied.
|
||||||
*
|
*
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
@ -117,11 +118,22 @@ signalhandler(int sig)
|
||||||
raise(sig);
|
raise(sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
terminate(int sig)
|
||||||
|
{
|
||||||
|
Cbuf_AddText("quit");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
registerHandler(void)
|
registerHandler(void)
|
||||||
{
|
{
|
||||||
|
/* Crash */
|
||||||
signal(SIGSEGV, signalhandler);
|
signal(SIGSEGV, signalhandler);
|
||||||
signal(SIGILL, signalhandler);
|
signal(SIGILL, signalhandler);
|
||||||
signal(SIGFPE, signalhandler);
|
signal(SIGFPE, signalhandler);
|
||||||
signal(SIGABRT, signalhandler);
|
signal(SIGABRT, signalhandler);
|
||||||
|
|
||||||
|
/* User abort */
|
||||||
|
signal(SIGINT, terminate);
|
||||||
|
signal(SIGTERM, terminate);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue