From 9ec4f7c7a4f4d56de6d00adbfe5d316edd0ec314 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 27 Sep 2023 09:55:57 +0200 Subject: [PATCH] exec-util: print executed commands in do_execute() 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c index 735334719ba..5da613bc17c 100644 --- a/src/shared/exec-util.c +++ b/src/shared/exec-util.c @@ -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; -- 2.47.3