github.com/gondor/docker@v1.9.0-rc1/daemon/execdriver/windows/terminatekill.go (about) 1 // +build windows 2 3 package windows 4 5 import ( 6 "github.com/Sirupsen/logrus" 7 "github.com/docker/docker/daemon/execdriver" 8 "github.com/microsoft/hcsshim" 9 ) 10 11 // Terminate implements the exec driver Driver interface. 12 func (d *Driver) Terminate(p *execdriver.Command) error { 13 logrus.Debugf("WindowsExec: Terminate() id=%s", p.ID) 14 return kill(p.ID, p.ContainerPid) 15 } 16 17 // Kill implements the exec driver Driver interface. 18 func (d *Driver) Kill(p *execdriver.Command, sig int) error { 19 logrus.Debugf("WindowsExec: Kill() id=%s sig=%d", p.ID, sig) 20 return kill(p.ID, p.ContainerPid) 21 } 22 23 func kill(id string, pid int) error { 24 logrus.Debugln("kill() ", id, pid) 25 var err error 26 27 // Terminate Process 28 if err = hcsshim.TerminateProcessInComputeSystem(id, uint32(pid)); err != nil { 29 logrus.Warnf("Failed to terminate pid %d in %s: %q", pid, id, err) 30 // Ignore errors 31 err = nil 32 } 33 34 if terminateMode { 35 // Terminate the compute system 36 if err = hcsshim.TerminateComputeSystem(id); err != nil { 37 logrus.Errorf("Failed to terminate %s - %q", id, err) 38 } 39 40 } else { 41 // Shutdown the compute system 42 if err = hcsshim.ShutdownComputeSystem(id); err != nil { 43 logrus.Errorf("Failed to shutdown %s - %q", id, err) 44 } 45 } 46 return err 47 }