Add DeleteProcess API for removing execs

We need a separate API for handing the exit status and deletion of
Exec'd processes to make sure they are properly cleaned up within the
shim and daemon.

Fixes #973

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-06-08 11:45:16 -07:00
parent 4e8548cd3f
commit ff598449d1
16 changed files with 646 additions and 225 deletions

View File

@@ -194,6 +194,28 @@ func (c *container) Checkpoint(ctx context.Context, opts plugin.CheckpointOpts)
return fmt.Errorf("Windows containers do not support checkpoint")
}
func (c *container) DeleteProcess(ctx context.Context, pid uint32) (*plugin.Exit, error) {
var process *hcs.Process
for _, p := range c.ctr.Processes() {
if p.Pid() == pid {
process = p
break
}
}
if process == nil {
return nil, fmt.Errorf("process %d not found", pid)
}
ec, err := process.ExitCode()
if err != nil {
return nil, err
}
process.Delete()
return &plugin.Exit{
Status: ec,
Timestamp: process.ExitedAt(),
}, nil
}
func (c *container) setStatus(status plugin.Status) {
c.Lock()
c.status = status