summaryrefslogtreecommitdiff
path: root/Monitor.c
diff options
context:
space:
mode:
authorAnna Czarnowska <anna.czarnowska@intel.com>2010-12-15 15:51:53 +1100
committerNeilBrown <neilb@suse.de>2010-12-15 15:51:53 +1100
commit44d337f04d35321084b4e309b4d68cf828bf7ec8 (patch)
tree102cfdd0914148e60dd0afcf094878b5e468d1c6 /Monitor.c
parent95d07a2cdd020ccde6c74d5d7c50bd7384816649 (diff)
fix: Monitor doesn't return after starting daemon
Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Monitor.c')
-rw-r--r--Monitor.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Monitor.c b/Monitor.c
index af701939..ce160f3e 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -152,9 +152,11 @@ int Monitor(struct mddev_dev *devlist,
info.mailfrom = mailfrom;
info.dosyslog = dosyslog;
- if (daemonise)
- if (make_daemon(pidfile))
- return 1;
+ if (daemonise) {
+ int rv = make_daemon(pidfile);
+ if (rv >= 0)
+ return rv;
+ }
if (share)
if (check_one_sharer(scan))
@@ -247,6 +249,12 @@ int Monitor(struct mddev_dev *devlist,
static int make_daemon(char *pidfile)
{
+ /* Return:
+ * -1 in the forked daemon
+ * 0 in the parent
+ * 1 on error
+ * so a none-negative becomes the exit code.
+ */
int pid = fork();
if (pid > 0) {
if (!pidfile)
@@ -272,7 +280,7 @@ static int make_daemon(char *pidfile)
dup2(0,1);
dup2(0,2);
setsid();
- return 0;
+ return -1;
}
static int check_one_sharer(int scan)