From 82aed82bf7ca3658a6ed67738be6446af100f6fb Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 3 Apr 2017 15:24:06 +0200 Subject: [PATCH] Increase verbosity and don't exit if PID file cannot be read --- daemon.c | 6 +++--- signals.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/daemon.c b/daemon.c index b67dc8ef..32536a8e 100644 --- a/daemon.c +++ b/daemon.c @@ -37,8 +37,6 @@ void test_singularity(void) { logg("WARNING: Unable to read PID from file (cannot read PID from file)."); logg(" Cannot test if another FTL process is running!"); - fclose(f); - exit(EXIT_FAILURE); } else { @@ -87,7 +85,7 @@ void go_daemon(void) // Indication of fork() failure if (process_id < 0) { - printf("fork failed!\n"); + logg("fork failed!\n"); // Return failure in exit status exit(EXIT_FAILURE); } @@ -104,10 +102,12 @@ void go_daemon(void) umask(0); //set new session + // creates a session and sets the process group ID sid = setsid(); if(sid < 0) { // Return failure + logg("setsid failed!\n"); exit(EXIT_FAILURE); } savepid(sid); diff --git a/signals.c b/signals.c index a5283516..6bd94e27 100644 --- a/signals.c +++ b/signals.c @@ -14,13 +14,14 @@ volatile sig_atomic_t killed = 0; static void SIGTERM_handler(int signum) { + logg("\nFATAL: FTL received SIGTERM, sheduled to exit gracefully\n"); killed = 1; } static void SIGINT_handler(int signum) { // Should probably not use printf in signal handler, but this will anyhow exit immediately - printf("\nFATAL: FTL received SIGINT (Ctrl + C), exiting immediately!\n"); + logg("\nFATAL: FTL received SIGINT (Ctrl + C), exiting immediately!\n"); exit(EXIT_FAILURE); }