From: Holger Schemel Date: Thu, 31 May 2018 11:04:13 +0000 (+0200) Subject: added handling SIGINT (Ctrl-C) to exit standalone network server X-Git-Tag: 4.1.1.0~126 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=359f8ed5f5c922fcbb78abce4b8648d354305759;p=rocksndiamonds.git added handling SIGINT (Ctrl-C) to exit standalone network server --- diff --git a/src/netserv.c b/src/netserv.c index 6555e049..71b23c95 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -433,6 +433,13 @@ static void Handle_OP_MOVE_PLAYER(struct NetworkServerPlayerInfo *player) ServerFrameCounter++; } +void ExitNetworkServer(int exit_value) +{ + Error(ERR_NETWORK_SERVER, "exiting network server"); + + exit(exit_value); +} + /* the following is not used for a standalone server; the pointer points to an integer containing the port-number */ int NetworkServerThread(void *ptr) @@ -458,6 +465,10 @@ void NetworkServer(int port, int serveronly) if (port == 0) port = DEFAULT_SERVER_PORT; + // if only running the network server, exit on Ctrl-C + if (serveronly) + signal(SIGINT, ExitNetworkServer); + if (!serveronly) onceonly = 1;