mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 02:56:18 +00:00
containerd-shim-kata-v2: add the service CloseIO support
Add the CloseIO api support to close a process's input stream. Signed-off-by: fupan <lifupan@gmail.com>
This commit is contained in:
parent
8c95b7569d
commit
ec4f27b4c6
@ -501,7 +501,30 @@ func (s *service) Pids(ctx context.Context, r *taskAPI.PidsRequest) (*taskAPI.Pi
|
||||
|
||||
// CloseIO of a process
|
||||
func (s *service) CloseIO(ctx context.Context, r *taskAPI.CloseIORequest) (*ptypes.Empty, error) {
|
||||
return nil, errdefs.ErrNotImplemented
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
c, err := s.getContainer(r.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tty := c.ttyio
|
||||
if r.ExecID != "" {
|
||||
execs, err := c.getExec(r.ExecID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tty = execs.ttyio
|
||||
}
|
||||
|
||||
if tty != nil && tty.Stdin != nil {
|
||||
if err := tty.Stdin.Close(); err != nil {
|
||||
return nil, errors.Wrap(err, "close stdin")
|
||||
}
|
||||
}
|
||||
|
||||
return empty, nil
|
||||
}
|
||||
|
||||
// Checkpoint the container
|
||||
|
Loading…
Reference in New Issue
Block a user