Add exec support to client
This also fixes a deadlock in the shim's reaper where execs would lockup and/or miss a quick exiting exec process's exit status. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -101,19 +101,18 @@ func (s *Service) Exec(ctx context.Context, r *shimapi.ExecRequest) (*shimapi.Ex
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.execID++
|
||||
reaper.Default.Lock()
|
||||
|
||||
process, err := newExecProcess(ctx, s.path, r, s.initProcess, s.execID)
|
||||
if err != nil {
|
||||
reaper.Default.Unlock()
|
||||
return nil, err
|
||||
}
|
||||
pid := process.Pid()
|
||||
s.processes[pid] = process
|
||||
cmd := &reaper.Cmd{
|
||||
ExitCh: make(chan int, 1),
|
||||
}
|
||||
reaper.Default.RegisterNL(pid, cmd)
|
||||
reaper.Default.Unlock()
|
||||
reaper.Default.Register(pid, cmd)
|
||||
s.processes[pid] = process
|
||||
|
||||
s.events <- &task.Event{
|
||||
Type: task.Event_EXEC_ADDED,
|
||||
ID: s.id,
|
||||
@@ -290,6 +289,8 @@ func (s *Service) Checkpoint(ctx context.Context, r *shimapi.CheckpointRequest)
|
||||
func (s *Service) waitExit(p process, pid int, cmd *reaper.Cmd) {
|
||||
status := <-cmd.ExitCh
|
||||
p.Exited(status)
|
||||
|
||||
reaper.Default.Delete(pid)
|
||||
s.events <- &task.Event{
|
||||
Type: task.Event_EXIT,
|
||||
ID: s.id,
|
||||
|
||||
Reference in New Issue
Block a user