|
@@ -3,6 +3,9 @@
|
|
package windows
|
|
package windows
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "fmt"
|
|
|
|
+ "syscall"
|
|
|
|
+
|
|
"github.com/Sirupsen/logrus"
|
|
"github.com/Sirupsen/logrus"
|
|
"github.com/docker/docker/daemon/execdriver"
|
|
"github.com/docker/docker/daemon/execdriver"
|
|
"github.com/microsoft/hcsshim"
|
|
"github.com/microsoft/hcsshim"
|
|
@@ -10,37 +13,36 @@ import (
|
|
|
|
|
|
// Terminate implements the exec driver Driver interface.
|
|
// Terminate implements the exec driver Driver interface.
|
|
func (d *Driver) Terminate(p *execdriver.Command) error {
|
|
func (d *Driver) Terminate(p *execdriver.Command) error {
|
|
- logrus.Debugf("WindowsExec: Terminate() id=%s", p.ID)
|
|
|
|
- return kill(p.ID, p.ContainerPid)
|
|
|
|
|
|
+ return kill(p.ID, p.ContainerPid, syscall.SIGTERM)
|
|
}
|
|
}
|
|
|
|
|
|
// Kill implements the exec driver Driver interface.
|
|
// Kill implements the exec driver Driver interface.
|
|
func (d *Driver) Kill(p *execdriver.Command, sig int) error {
|
|
func (d *Driver) Kill(p *execdriver.Command, sig int) error {
|
|
- logrus.Debugf("WindowsExec: Kill() id=%s sig=%d", p.ID, sig)
|
|
|
|
- return kill(p.ID, p.ContainerPid)
|
|
|
|
|
|
+ return kill(p.ID, p.ContainerPid, syscall.Signal(sig))
|
|
}
|
|
}
|
|
|
|
|
|
-func kill(id string, pid int) error {
|
|
|
|
- logrus.Debugln("kill() ", id, pid)
|
|
|
|
|
|
+func kill(id string, pid int, sig syscall.Signal) error {
|
|
|
|
+ logrus.Debugf("WindowsExec: kill() id=%s pid=%d sig=%d", id, pid, sig)
|
|
var err error
|
|
var err error
|
|
|
|
+ context := fmt.Sprintf("kill: sig=%d pid=%d", sig, pid)
|
|
|
|
|
|
- // Terminate Process
|
|
|
|
- if err = hcsshim.TerminateProcessInComputeSystem(id, uint32(pid)); err != nil {
|
|
|
|
- logrus.Warnf("Failed to terminate pid %d in %s: %q", pid, id, err)
|
|
|
|
- // Ignore errors
|
|
|
|
- err = nil
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if terminateMode {
|
|
|
|
|
|
+ if sig == syscall.SIGKILL || forceKill {
|
|
// Terminate the compute system
|
|
// Terminate the compute system
|
|
- if err = hcsshim.TerminateComputeSystem(id); err != nil {
|
|
|
|
- logrus.Errorf("Failed to terminate %s - %q", id, err)
|
|
|
|
|
|
+ if errno, err := hcsshim.TerminateComputeSystem(id, hcsshim.TimeoutInfinite, context); err != nil {
|
|
|
|
+ logrus.Errorf("Failed to terminate %s - 0x%X %q", id, errno, err)
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
+ // Terminate Process
|
|
|
|
+ if err = hcsshim.TerminateProcessInComputeSystem(id, uint32(pid)); err != nil {
|
|
|
|
+ logrus.Warnf("Failed to terminate pid %d in %s: %q", pid, id, err)
|
|
|
|
+ // Ignore errors
|
|
|
|
+ err = nil
|
|
|
|
+ }
|
|
|
|
+
|
|
// Shutdown the compute system
|
|
// Shutdown the compute system
|
|
- if err = hcsshim.ShutdownComputeSystem(id); err != nil {
|
|
|
|
- logrus.Errorf("Failed to shutdown %s - %q", id, err)
|
|
|
|
|
|
+ if errno, err := hcsshim.ShutdownComputeSystem(id, hcsshim.TimeoutInfinite, context); err != nil {
|
|
|
|
+ logrus.Errorf("Failed to shutdown %s - 0x%X %q", id, errno, err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return err
|
|
return err
|