Remove sigchld reaper from containerd process

Because we are launching alot of different runc commands to do
operations there is a race between doing a `cmd.Wait()` and getting the
sigchld and reaping it.  We can remove the sigchild reaper from
containerd as long as we make sure we reap the shim process if we are
the parent, i.e. not restored.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-04-27 12:00:29 -07:00
parent 25de9de446
commit 847690583f
5 changed files with 21 additions and 8 deletions

View file

@ -6,6 +6,7 @@ import (
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strconv"
"syscall"
@ -39,6 +40,8 @@ type Process interface {
SystemPid() int
// State returns if the process is running or not
State() State
// Wait reaps the shim process if avaliable
Wait()
}
type processConfig struct {
@ -139,6 +142,7 @@ type process struct {
container *container
spec specs.ProcessSpec
stdio Stdio
cmd *exec.Cmd
}
func (p *process) ID() string {
@ -219,6 +223,13 @@ func (p *process) getPidFromFile() (int, error) {
return i, nil
}
// Wait will reap the shim process
func (p *process) Wait() {
if p.cmd != nil {
p.cmd.Wait()
}
}
func getExitPipe(path string) (*os.File, error) {
if err := syscall.Mkfifo(path, 0755); err != nil && !os.IsExist(err) {
return nil, err