Ensure a reliable way to kill ghost containers on reboot

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-03-26 06:48:16 +00:00
parent 345365e7b0
commit b16b1a04ff
3 changed files with 44 additions and 5 deletions

View file

@ -50,8 +50,13 @@ func (ns *linuxNs) Exec(container *libcontainer.Container, term Terminal, args [
if err := command.Start(); err != nil {
return -1, err
}
started, err := system.GetProcessStartTime(command.Process.Pid)
if err != nil {
return -1, err
}
ns.logger.Printf("writting pid %d to file\n", command.Process.Pid)
if err := ns.stateWriter.WritePid(command.Process.Pid); err != nil {
if err := ns.stateWriter.WritePid(command.Process.Pid, started); err != nil {
command.Process.Kill()
return -1, err
}