Skip to content

Commit

Permalink
fix: wait for async command exit (#1326)
Browse files Browse the repository at this point in the history
This prevents the accumulation of zombie processes when using
async (&) event commands. Also log async command failures.
  • Loading branch information
juergenhoetzel committed Mar 14, 2021
1 parent 381f090 commit 6d5ceae
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit 6d5ceae

Please sign in to comment.