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"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -121,12 +122,22 @@ func (d *driver) Restore(c *execdriver.Command) error {
|
||||||
}
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
|
|
||||||
proc, err := os.FindProcess(nspid)
|
if _, err := os.FindProcess(nspid); err != nil {
|
||||||
if err != nil {
|
return fmt.Errorf("finding existing pid %d %s", nspid, err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
_, err = proc.Wait()
|
c.Process = &os.Process{
|
||||||
return err
|
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 {
|
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 {
|
if err := setupNewMountNamespace(rootfs, console, container.ReadonlyFs); err != nil {
|
||||||
return fmt.Errorf("setup mount namespace %s", err)
|
return fmt.Errorf("setup mount namespace %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue