mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Revert "Do not wait for container on stop if the process doesn't exist."
This reverts commit 1a10104d85
.
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
f4dd90f40a
commit
0e4f9457c0
2 changed files with 3 additions and 28 deletions
|
@ -1093,9 +1093,7 @@ func killProcessDirectly(container *container.Container) error {
|
|||
if err != syscall.ESRCH {
|
||||
return err
|
||||
}
|
||||
e := errNoSuchProcess{pid, 9}
|
||||
logrus.Debug(e)
|
||||
return e
|
||||
logrus.Debugf("Cannot kill process (pid=%d) with signal 9: no such process.", pid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,22 +12,6 @@ import (
|
|||
"github.com/docker/docker/pkg/signal"
|
||||
)
|
||||
|
||||
type errNoSuchProcess struct {
|
||||
pid int
|
||||
signal int
|
||||
}
|
||||
|
||||
func (e errNoSuchProcess) Error() string {
|
||||
return fmt.Sprintf("Cannot kill process (pid=%d) with signal %d: no such process.", e.pid, e.signal)
|
||||
}
|
||||
|
||||
// isErrNoSuchProcess returns true if the error
|
||||
// is an instance of errNoSuchProcess.
|
||||
func isErrNoSuchProcess(err error) bool {
|
||||
_, ok := err.(errNoSuchProcess)
|
||||
return ok
|
||||
}
|
||||
|
||||
// ContainerKill send signal to the container
|
||||
// If no signal is given (sig 0), then Kill with SIGKILL and wait
|
||||
// for the container to exit.
|
||||
|
@ -103,9 +87,6 @@ func (daemon *Daemon) Kill(container *container.Container) error {
|
|||
// So, instead we'll give it up to 2 more seconds to complete and if
|
||||
// by that time the container is still running, then the error
|
||||
// we got is probably valid and so we return it to the caller.
|
||||
if isErrNoSuchProcess(err) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if container.IsRunning() {
|
||||
container.WaitStop(2 * time.Second)
|
||||
|
@ -117,9 +98,6 @@ func (daemon *Daemon) Kill(container *container.Container) error {
|
|||
|
||||
// 2. Wait for the process to die, in last resort, try to kill the process directly
|
||||
if err := killProcessDirectly(container); err != nil {
|
||||
if isErrNoSuchProcess(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -131,9 +109,8 @@ func (daemon *Daemon) Kill(container *container.Container) error {
|
|||
func (daemon *Daemon) killPossiblyDeadProcess(container *container.Container, sig int) error {
|
||||
err := daemon.killWithSignal(container, sig)
|
||||
if err == syscall.ESRCH {
|
||||
e := errNoSuchProcess{container.GetPID(), sig}
|
||||
logrus.Debug(e)
|
||||
return e
|
||||
logrus.Debugf("Cannot kill process (pid=%d) with signal %d: no such process.", container.GetPID(), sig)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue