github.com/akerouanton/docker@v1.11.0-rc3/libcontainerd/client_shutdownrestore_linux.go (about) 1 // +build !experimental 2 3 package libcontainerd 4 5 import ( 6 "syscall" 7 "time" 8 9 "github.com/Sirupsen/logrus" 10 ) 11 12 func (clnt *client) Restore(containerID string, options ...CreateOption) error { 13 w := clnt.getOrCreateExitNotifier(containerID) 14 defer w.close() 15 cont, err := clnt.getContainerdContainer(containerID) 16 if err == nil && cont.Status != "stopped" { 17 clnt.lock(cont.Id) 18 container := clnt.newContainer(cont.BundlePath) 19 container.systemPid = systemPid(cont) 20 clnt.appendContainer(container) 21 clnt.unlock(cont.Id) 22 23 if err := clnt.Signal(containerID, int(syscall.SIGTERM)); err != nil { 24 logrus.Errorf("error sending sigterm to %v: %v", containerID, err) 25 } 26 select { 27 case <-time.After(10 * time.Second): 28 if err := clnt.Signal(containerID, int(syscall.SIGKILL)); err != nil { 29 logrus.Errorf("error sending sigkill to %v: %v", containerID, err) 30 } 31 select { 32 case <-time.After(2 * time.Second): 33 case <-w.wait(): 34 return nil 35 } 36 case <-w.wait(): 37 return nil 38 } 39 } 40 return clnt.setExited(containerID) 41 }