Browse code

Send sigterm to child instead of sigkill Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)

Michael Crosby authored on 2014/03/15 03:42:01
Showing 2 changed files
... ...
@@ -48,7 +48,9 @@ func (ns *linuxNs) Init(container *libcontainer.Container, uncleanRootfs, consol
48 48
 			return fmt.Errorf("setctty %s", err)
49 49
 		}
50 50
 	}
51
-	if err := system.ParentDeathSignal(); err != nil {
51
+	// this is our best effort to let the process know that the parent has died and that it
52
+	// should it should act on it how it sees fit
53
+	if err := system.ParentDeathSignal(uintptr(syscall.SIGTERM)); err != nil {
52 54
 		return fmt.Errorf("parent death signal %s", err)
53 55
 	}
54 56
 	if err := setupNewMountNamespace(rootfs, container.Mounts, console, container.ReadonlyFs, container.NoPivotRoot); err != nil {
... ...
@@ -115,8 +115,8 @@ func Mknod(path string, mode uint32, dev int) error {
115 115
 	return syscall.Mknod(path, mode, dev)
116 116
 }
117 117
 
118
-func ParentDeathSignal() error {
119
-	if _, _, err := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_SET_PDEATHSIG, uintptr(syscall.SIGKILL), 0); err != 0 {
118
+func ParentDeathSignal(sig uintptr) error {
119
+	if _, _, err := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_SET_PDEATHSIG, sig, 0); err != 0 {
120 120
 		return err
121 121
 	}
122 122
 	return nil