Skip to content

Commit

Permalink
set a specific flag when sharing pid namespace
Browse files Browse the repository at this point in the history
because we cant depends on CloneFlags now, setting a separate flag to indicate
that the current container shares pid namespace so init process can clean up
properly.

Signed-off-by: Daniel, Dao Quang Minh <[email protected]>
  • Loading branch information
dqminh committed Sep 1, 2015
1 parent 759ba54 commit 2142fbc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func (c *linuxContainer) newInitProcess(p *Process, cmd *exec.Cmd, parentPipe, c
nsMaps[ns.Type] = ns.Path
}
}
_, sharePidns := nsMaps[configs.NEWPID]
data, err := c.bootstrapData(cmd, c.config.Namespaces.CloneFlags(), nsMaps, "")
if err != nil {
return nil, err
Expand All @@ -185,6 +186,7 @@ func (c *linuxContainer) newInitProcess(p *Process, cmd *exec.Cmd, parentPipe, c
manager: c.cgroupManager,
config: c.newInitConfig(p),
bootstrapData: data,
sharePidns: sharePidns,
}, nil
}

Expand Down
5 changes: 2 additions & 3 deletions libcontainer/process_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ type initProcess struct {
container *linuxContainer
fds []string
bootstrapData io.Reader
sharePidns bool
}

func (p *initProcess) pid() int {
Expand Down Expand Up @@ -264,9 +265,7 @@ func (p *initProcess) wait() (*os.ProcessState, error) {
return p.cmd.ProcessState, err
}
// we should kill all processes in cgroup when init is died if we use host PID namespace
// FIXME: instead of checking here, we should check when create the init
// process
if p.cmd.SysProcAttr.Cloneflags&syscall.CLONE_NEWPID == 0 {
if p.sharePidns {
killCgroupProcesses(p.manager)
}
return p.cmd.ProcessState, nil
Expand Down

0 comments on commit 2142fbc

Please sign in to comment.