mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Allow child process to live if daemon dies
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
a115ce797b
commit
fdeea90fc8
2 changed files with 21 additions and 8 deletions
|
@ -15,6 +15,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -121,12 +122,22 @@ func (d *driver) Restore(c *execdriver.Command) error {
|
|||
}
|
||||
f.Close()
|
||||
|
||||
proc, err := os.FindProcess(nspid)
|
||||
if err != nil {
|
||||
return err
|
||||
if _, err := os.FindProcess(nspid); err != nil {
|
||||
return fmt.Errorf("finding existing pid %d %s", nspid, err)
|
||||
}
|
||||
_, err = proc.Wait()
|
||||
return err
|
||||
c.Process = &os.Process{
|
||||
Pid: nspid,
|
||||
}
|
||||
|
||||
for _ = range time.Tick(500 * time.Millisecond) {
|
||||
if err := syscall.Kill(nspid, 0); err != nil {
|
||||
if strings.Contains(err.Error(), "no such process") {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("signal error %s", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *driver) Info(id string) execdriver.Info {
|
||||
|
|
|
@ -50,9 +50,11 @@ func (ns *linuxNs) Init(container *libcontainer.Container, uncleanRootfs, consol
|
|||
}
|
||||
}
|
||||
|
||||
if err := system.ParentDeathSignal(); err != nil {
|
||||
return fmt.Errorf("parent deth signal %s", err)
|
||||
}
|
||||
/*
|
||||
if err := system.ParentDeathSignal(); err != nil {
|
||||
return fmt.Errorf("parent death signal %s", err)
|
||||
}
|
||||
*/
|
||||
if err := setupNewMountNamespace(rootfs, console, container.ReadonlyFs); err != nil {
|
||||
return fmt.Errorf("setup mount namespace %s", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue