Wait for async command exit

This prevents the accumulation of zombie processes when using
async (&) event commands. Also log async command failures.
This commit is contained in:
Juergen Hoetzel 2021-03-14 17:23:55 +01:00
parent fc5506179a
commit 631f3f5a62

View File

@ -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()
}