]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
exec-util: print executed commands in do_execute() 29361/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 27 Sep 2023 07:55:57 +0000 (09:55 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 28 Sep 2023 10:46:22 +0000 (12:46 +0200)
kernel-install uses do_execute(). We would log whenever a spawned child
finished, but we would not log anything when the child is launched. When the
children log output without a prefix (as the kernel-install plugins do), it
is hard to see where that output is coming from.

src/shared/exec-util.c

index 735334719ba0880c4be91717a09fcd2130fe6732..5da613bc17c114b1c3ee486f8a418cf3cced0629 100644 (file)
@@ -12,6 +12,7 @@
 #include "env-file.h"
 #include "env-util.h"
 #include "errno-util.h"
+#include "escape.h"
 #include "exec-util.h"
 #include "fd-util.h"
 #include "fileio.h"
@@ -138,6 +139,14 @@ static int do_execute(
                                 return log_error_errno(fd, "Failed to open serialization file: %m");
                 }
 
+                if (DEBUG_LOGGING) {
+                        _cleanup_free_ char *args = NULL;
+                        if (argv)
+                                args = quote_command_line(strv_skip(argv, 1), SHELL_ESCAPE_EMPTY);
+
+                        log_debug("About to execute %s%s%s", t, argv ? " " : "", argv ? strnull(args) : "");
+                }
+
                 r = do_spawn(t, argv, fd, &pid, FLAGS_SET(flags, EXEC_DIR_SET_SYSTEMD_EXEC_PID));
                 if (r <= 0)
                         continue;