Skip to content

Commit

Permalink
Merge pull request #1930 from crosbymichael/proc-exists
Browse files Browse the repository at this point in the history
Check that process exists before it is returned
  • Loading branch information
mlaventure committed Dec 27, 2017
2 parents c07ede4 + c6b8e57 commit 3fa104f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion linux/shim/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ func (s *Service) ResizePty(ctx context.Context, r *shimapi.ResizePtyRequest) (*
// State returns runtime state information for a process
func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi.StateResponse, error) {
s.mu.Lock()
defer s.mu.Unlock()
p := s.processes[r.ID]
s.mu.Unlock()
if p == nil {
return nil, errdefs.ToGRPCf(errdefs.ErrNotFound, "process id %s not found", r.ID)
}
Expand Down
9 changes: 6 additions & 3 deletions linux/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,14 @@ func (t *Task) Update(ctx context.Context, resources *types.Any) error {

// Process returns a specific process inside the task by the process id
func (t *Task) Process(ctx context.Context, id string) (runtime.Process, error) {
// TODO: verify process exists for container
return &Process{
p := &Process{
id: id,
t: t,
}, nil
}
if _, err := p.State(ctx); err != nil {
return nil, err
}
return p, nil
}

// Metrics returns runtime specific system level metric information for the task
Expand Down

0 comments on commit 3fa104f

Please sign in to comment.