From 2d2dfab85a772165b2b498b54a690f55df5fa2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kenfe-Micka=C3=ABl=20Laventure?= Date: Thu, 16 Jun 2016 14:38:28 -0700 Subject: [PATCH] Set parent death signal to all exec within the shim (#269) This will prevent from leaving hung processes around if there's a bug in the runtime. Signed-off-by: Kenfe-Mickael Laventure --- containerd-shim/process.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/containerd-shim/process.go b/containerd-shim/process.go index ab923b8..c0abfc9 100644 --- a/containerd-shim/process.go +++ b/containerd-shim/process.go @@ -222,6 +222,7 @@ func (p *process) start() error { cmd.Stdin = p.stdio.stdin cmd.Stdout = p.stdio.stdout cmd.Stderr = p.stdio.stderr + cmd.SysProcAttr = setPDeathSig() return cmd.Run() } @@ -231,7 +232,9 @@ func (p *process) pid() int { func (p *process) delete() error { if !p.state.Exec { - out, err := exec.Command(p.runtime, append(p.state.RuntimeArgs, "delete", p.id)...).CombinedOutput() + cmd := exec.Command(p.runtime, append(p.state.RuntimeArgs, "delete", p.id)...) + cmd.SysProcAttr = setPDeathSig() + out, err := cmd.CombinedOutput() if err != nil { return fmt.Errorf("%s: %v", out, err) }