From bd6a1b81dbef5ece4e4cea3e003eef4a03c8a9fd Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 28 Dec 2006 18:26:21 +0000 Subject: [PATCH] Fixed pidfile handling --- webcit/setup.c | 1 - webcit/webserver.c | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/webcit/setup.c b/webcit/setup.c index 1baca4c20..9d64a5dcc 100644 --- a/webcit/setup.c +++ b/webcit/setup.c @@ -421,7 +421,6 @@ void install_init_scripts(void) fprintf(fp, "CTDL_HOSTNAME=%s\n", hostname); fprintf(fp, "CTDL_PORTNAME=%s\n", portname); fprintf(fp, "\n" - "test -d /var/run || exit 0\n" "\n" "case \"$1\" in\n" "\n" diff --git a/webcit/webserver.c b/webcit/webserver.c index fe23a8489..3af120551 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -480,21 +480,14 @@ void start_daemon(char *pid_file) */ chdir("/"); + signal(SIGHUP, SIG_IGN); + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + child = fork(); if (child != 0) { - if (pid_file) { - fp = fopen(pid_file, "w"); - if (fp != NULL) { - fprintf(fp, "%d\n", child); - fclose(fp); - } - } exit(0); } - - signal(SIGHUP, SIG_IGN); - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); setsid(); umask(0); @@ -518,6 +511,13 @@ void start_daemon(char *pid_file) else { signal(SIGTERM, SIG_IGN); + if (pid_file) { + fp = fopen(pid_file, "w"); + if (fp != NULL) { + fprintf(fp, "%d\n", current_child); + fclose(fp); + } + } waitpid(current_child, &status, 0); } -- 2.39.2