From 6d5ceae8b454edd749b3b65c88aacc0a31ce9215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20H=C3=B6tzel?= Date: Sun, 14 Mar 2021 19:32:14 +0100 Subject: [PATCH] fix: wait for async command exit (#1326) This prevents the accumulation of zombie processes when using async (&) event commands. Also log async command failures. --- runner/runner.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runner/runner.go b/runner/runner.go index c0e30985..2dbafa5c 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -102,6 +102,14 @@ func (r *Runner) exec(raw, evt, path, dst string, user *users.User) error { if !blocking { log.Printf("[INFO] Nonblocking Command: \"%s\"", strings.Join(command, " ")) + defer func() { + go func() { + err := cmd.Wait() + if err != nil { + log.Printf("[INFO] Nonblocking Command \"%s\" failed: %s", strings.Join(command, " "), err) + } + }() + }() return cmd.Start() }