aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2024-01-07 18:36:59 +0200
committerSyndamia <kamen@syndamia.com>2024-01-07 18:36:59 +0200
commite540facf3bc4f2cecf36b9a4e6dd62929ef34a11 (patch)
treeaff314e09b7718b7118d23c105804240430b0087
parentb625711d92fc6bd2db04a1ce9bb1c3bd9ce6db47 (diff)
downloadpico-web-e540facf3bc4f2cecf36b9a4e6dd62929ef34a11.tar
pico-web-e540facf3bc4f2cecf36b9a4e6dd62929ef34a11.tar.gz
pico-web-e540facf3bc4f2cecf36b9a4e6dd62929ef34a11.zip
(server-cli) Fixed infinite output when stdout is closed
-rw-r--r--src/server-cli.c8
1 files changed, 7 insertions, 1 deletions
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 <stdio.h>
#include <signal.h>
#include <unistd.h>
+#include <fcntl.h>
#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