multipathd: cleanup foreground operation
authorHannes Reinecke <hare@suse.de>
Tue, 24 Jun 2014 06:28:39 +0000 (08:28 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Sun, 29 Mar 2015 15:58:12 +0000 (17:58 +0200)
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@suse.de>
multipathd/main.c

index 494f4bb..ac1e1a2 100644 (file)
@@ -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;