From 46b84f1bcc6bad0fb848d1d738d7a41ebff6f9d1 Mon Sep 17 00:00:00 2001 From: Marc Hoersken Date: Thu, 23 May 2024 20:24:50 +0200 Subject: [PATCH] Avoid parent process if no log redirection is used Exec the command without forking in case go-runner does not need to perform log output redirection. Signed-off-by: Marc Hoersken --- images/build/go-runner/go-runner.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/images/build/go-runner/go-runner.go b/images/build/go-runner/go-runner.go index 74762b39fc60..2b65af27912e 100644 --- a/images/build/go-runner/go-runner.go +++ b/images/build/go-runner/go-runner.go @@ -79,6 +79,10 @@ func configureAndRun() error { cmd.Stderr = errStream log.Printf("Running command:\n%v", cmdInfo(cmd)) + if cmd.Stdout == os.Stdout && cmd.Stderr == os.Stderr { + syscall.Exec(exe, exeArgs, syscall.Environ()) + } + err := cmd.Start() if err != nil { return fmt.Errorf("starting command: %w", err)