Skip to content

Commit

Permalink
Merge pull request moby#5342 from danielnorberg/avoid-suicide
Browse files Browse the repository at this point in the history
avoid suicide
  • Loading branch information
unclejack committed Apr 25, 2014
2 parents ed48608 + b3ddc31 commit 077b7d0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions daemon/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,12 @@ func (container *Container) Kill() error {

// 2. Wait for the process to die, in last resort, try to kill the process directly
if err := container.WaitTimeout(10 * time.Second); err != nil {
log.Printf("Container %s failed to exit within 10 seconds of kill - trying direct SIGKILL", utils.TruncateID(container.ID))
if err := syscall.Kill(container.State.Pid, 9); err != nil {
return err
// Ensure that we don't kill ourselves
if pid := container.State.Pid; pid != 0 {
log.Printf("Container %s failed to exit within 10 seconds of kill - trying direct SIGKILL", utils.TruncateID(container.ID))
if err := syscall.Kill(pid, 9); err != nil {
return err
}
}
}

Expand Down

0 comments on commit 077b7d0

Please sign in to comment.