[git commit] mdev: clear LOGMODE_STDIO only directly before daemonizing

Denys Vlasenko vda.linux at googlemail.com
Sun Nov 22 15:35:56 UTC 2020


commit: https://git.busybox.net/busybox/commit/?id=03eb6eba436ca6198e5346ebb9d22a30d2f527a4
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 util-linux/mdev.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 2cf98b1a4..9a8c14456 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -1279,21 +1279,17 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
 
 #if ENABLE_FEATURE_MDEV_DAEMON
 	if (opt & MDEV_OPT_DAEMON) {
-		int fd;
-
-		/* there is no point in write()ing to /dev/null */
-		if (!(opt & MDEV_OPT_FOREGROUND))
-			logmode &= ~LOGMODE_STDIO;
-
-		/*
-		 * Daemon mode listening on uevent netlink socket. Fork away
+		/* Daemon mode listening on uevent netlink socket. Fork away
 		 * after initial scan so that caller can be sure everything
 		 * is up-to-date when mdev process returns.
 		 */
-		fd = daemon_init(temp);
+		int fd = daemon_init(temp);
 
-		if (!(opt & MDEV_OPT_FOREGROUND))
+		if (!(opt & MDEV_OPT_FOREGROUND)) {
+			/* there is no point in logging to /dev/null */
+			logmode &= ~LOGMODE_STDIO;
 			bb_daemonize_or_rexec(0, argv);
+		}
 
 		daemon_loop(temp, fd);
 	}


More information about the busybox-cvs mailing list