From 359f8ed5f5c922fcbb78abce4b8648d354305759 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Thu, 31 May 2018 13:04:13 +0200 Subject: [PATCH] added handling SIGINT (Ctrl-C) to exit standalone network server --- src/netserv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; -- 2.34.1