Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
containerd-shim-kata-v2: add the service wait support
Browse files Browse the repository at this point in the history
Add the Wait api to wait on a started container
or exec process.

Signed-off-by: fupan <lifupan@gmail.com>
  • Loading branch information
lifupan committed Nov 28, 2018
1 parent 269c940 commit fbaefc9
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion containerd-shim-v2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,30 @@ func (s *service) Update(ctx context.Context, r *taskAPI.UpdateTaskRequest) (*pt

// Wait for a process to exit
func (s *service) Wait(ctx context.Context, r *taskAPI.WaitRequest) (*taskAPI.WaitResponse, error) {
return nil, errdefs.ErrNotImplemented
var ret uint32

s.Lock()
c, err := s.getContainer(r.ID)
s.Unlock()

if err != nil {
return nil, err
}

//wait for container
if r.ExecID == "" {
ret = <-c.exitCh
} else { //wait for exec
execs, err := c.getExec(r.ExecID)
if err != nil {
return nil, err
}
ret = <-execs.exitCh
}

return &taskAPI.WaitResponse{
ExitStatus: ret,
}, nil
}

func (s *service) processExits() {
Expand Down

0 comments on commit fbaefc9

Please # to comment.