Website Summary Files Commits Branches @commit @diff @stats
path: root / src / server-cli.c
diff options
context:
space:
mode:
Commite540facf3bc4f2cecf36b9a4e6dd62929ef34a11 (patch)
Author
 Syndamia <kamen@syndamia.com>
2024-01-07 18:36:59 +0200
Committer
 Syndamia <kamen@syndamia.com>
2024-01-07 18:36:59 +0200
Filesaff314e09b7718b7118d23c105804240430b0087 /src/server-cli.c
pico-web-e540facf3bc4f2cecf36b9a4e6dd62929ef34a11.tar
pico-web-e540facf3bc4f2cecf36b9a4e6dd62929ef34a11.tar.gz
pico-web-e540facf3bc4f2cecf36b9a4e6dd62929ef34a11.zip
Parentb625711d92fc6bd2db04a1ce9bb1c3bd9ce6db47 (diff)
(server-cli) Fixed infinite output when stdout is closed
1 files changed, 7 insertions, 1 deletions
-rw-r--r--src/server-cli.c8
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