[dm-devel] [PATCH 29/78] multipathd: cleanup foreground operation

Hannes Reinecke hare at suse.de
Mon Mar 16 12:36:16 UTC 2015


When specifying '-d' it actually does two things, namely do not
daemonize the program and prints logging messages to stdout
instead of syslog.
This partially clashes with '-s' which suppresses the timestamp
printing. So separate both use cases and ensure that '-d' doesn't
overwrite '-s' if specified later.

Signed-off-by: Hannes Reinecke <hare at suse.de>
---
 multipathd/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index 494f4bb..ac1e1a2 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1998,6 +1998,7 @@ main (int argc, char *argv[])
 	extern int optind;
 	int arg;
 	int err;
+	int foreground = 0;
 
 	logsink = 1;
 	running_state = DAEMON_INIT;
@@ -2022,7 +2023,9 @@ main (int argc, char *argv[])
 	while ((arg = getopt(argc, argv, ":dsv:k::B")) != EOF ) {
 	switch(arg) {
 		case 'd':
-			logsink = 0;
+			foreground = 1;
+			if (logsink > 0)
+				logsink = 0;
 			//debug=1; /* ### comment me out ### */
 			break;
 		case 'v':
@@ -2062,7 +2065,7 @@ main (int argc, char *argv[])
 		exit(0);
 	}
 
-	if (logsink < 1) {
+	if (foreground) {
 		if (!isatty(fileno(stdout)))
 			setbuf(stdout, NULL);
 		err = 0;
-- 
1.8.4.5




More information about the dm-devel mailing list