Thread (27 messages) 27 messages, 5 authors, 2010-12-23

Re: [PATCH] fix: Monitor doesn't return after starting daemon

From: Neil Brown <hidden>
Date: 2010-12-14 21:58:14

On Tue, 14 Dec 2010 14:47:27 +0000 "Czarnowska, Anna"
[off-list ref] wrote:
quoted
From 8b2465b0d314cc93bba5797dbad9fd2813f0a79e Mon Sep 17 00:00:00 2001
From: Anna Czarnowska <redacted>
Date: Tue, 14 Dec 2010 12:26:33 +0100
Subject: [PATCH] fix: Monitor doesn't return after starting daemon
Cc: linux-raid@vger.kernel.org, Williams, Dan J <redacted>, Ciechanowski, Ed <redacted>

Because both parent and child process continue after make_daemon succeeds.
Applied, thanks.

NeilBrown

quoted hunk ↗ jump to hunk
Signed-off-by: Anna Czarnowska <redacted>
---
 Monitor.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index e7f6d03..4ae1d2b 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))
@@ -272,7 +274,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)
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help