From e540facf3bc4f2cecf36b9a4e6dd62929ef34a11 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 7 Jan 2024 18:36:59 +0200 Subject: (server-cli) Fixed infinite output when stdout is closed --- src/server-cli.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/server-cli.c b/src/server-cli.c index 58e5ea4..707c3ef 100644 --- a/src/server-cli.c +++ b/src/server-cli.c @@ -3,14 +3,20 @@ #include #include #include +#include #define MAX_LEN_COMMAND 16 #define COMMAND_FORMAT ": %16s" void handleCLI(sds **vhosts, int vhostsc) { + // Is stdin available + // Get a line char line[256]; - fgets(line, 256, stdin); + if (fgets(line, 256, stdin) == NULL) { + printf("Couldn't read from standard input! User input can not and will not be handled!\nYou'll have to manually kill the server process to shut it down!\n"); + return; + } // Get command name and it's arguments // Currently no command takes arguments -- cgit v1.2.3