]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: print warning in a failure case of make_null_stdio() (#4320)
author0xAX <0xAX@users.noreply.github.com>
Mon, 10 Oct 2016 02:55:24 +0000 (05:55 +0300)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 10 Oct 2016 02:55:24 +0000 (22:55 -0400)
The make_null_stdio() may fail. Let's check its result and print
warning message instead of keeping silence.

src/core/main.c
src/udev/udevd.c

index 6fe440277ecca6237aad07ff04cf3017b6ff5f18..e88362b7fe66bdecc824b9a5374e745bab544342 100644 (file)
@@ -1532,7 +1532,8 @@ int main(int argc, char *argv[]) {
                  * need to do that for user instances since they never log
                  * into the console. */
                 log_show_color(colors_enabled());
-                make_null_stdio();
+                if (make_null_stdio() < 0)
+                        log_warning_errno(errno, "Failed to redirect standard streams to /dev/null: %m");
         }
 
         /* Initialize default unit */
index 19f1c2919841f5935ac44b60ce2ceaf978c6da4c..6000d9c7ec6c23ed58f0b9d5ee1ea5661c39e1ea 100644 (file)
@@ -1739,7 +1739,9 @@ int main(int argc, char *argv[]) {
 
                 /* connect /dev/null to stdin, stdout, stderr */
                 if (log_get_max_level() < LOG_DEBUG)
-                        (void) make_null_stdio();
+                        if (make_null_stdio() < 0)
+                                log_warning_errno(errno, "Failed to redirect standard streams to /dev/null: %m");
+
 
                 pid = fork();
                 switch (pid) {