fix: wait for async command exit (#1326)

This prevents the accumulation of zombie processes when using
async (&) event commands. Also log async command failures.
This commit is contained in:
Jürgen Hötzel 2021-03-14 19:32:14 +01:00 committed by GitHub
parent 381f09087a
commit 6d5ceae8b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -102,6 +102,14 @@ func (r *Runner) exec(raw, evt, path, dst string, user *users.User) error {
if !blocking { if !blocking {
log.Printf("[INFO] Nonblocking Command: \"%s\"", strings.Join(command, " ")) 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() return cmd.Start()
} }