Skip to content

Commit

Permalink
nil checks in command code
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Peterson committed Sep 19, 2015
1 parent a9be86b commit 4a03e8d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions util/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ func Command(timeout time.Duration, stdin io.Reader, name string, arg ...string)
case err := <-done:
return &b, err
case <-interrupt:
c.Process.Signal(os.Interrupt)
if c.Process != nil {
c.Process.Signal(os.Interrupt)
}
case <-kill:
// todo: figure out if this can leave the done chan hanging open
c.Process.Kill()
if c.Process != nil {
c.Process.Kill()
}
return nil, ErrTimeout
}
}
Expand Down

1 comment on commit 4a03e8d

@kylebrandt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a danger here of:

  • Process doesn't get created, maybe because it takes over 10 seconds to start (as crazy as that would be)
  • func returns
  • Process finally starts AND gets hung
  • Nothing to kill process?

Also we should probably log interrupts?

Please sign in to comment.