Skip to content

Commit

Permalink
Fix closing stdin (#1899)
Browse files Browse the repository at this point in the history
Send the modify request even if stdin is nil, let the process handle it

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
(cherry picked from commit 27df1b9)
Signed-off-by: Maksim An <maksiman@microsoft.com>
  • Loading branch information
rumpl authored and anmaxvl committed Sep 20, 2023
1 parent b497608 commit 641f8b8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions internal/hcs/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,6 @@ func (process *Process) CloseStdin(ctx context.Context) (err error) {
return makeProcessError(process, operation, ErrAlreadyClosed, nil)
}

process.stdioLock.Lock()
defer process.stdioLock.Unlock()
if process.stdin == nil {
return nil
}

//HcsModifyProcess request to close stdin will fail if the process has already exited
if !process.stopped() {
modifyRequest := processModifyRequest{
Expand All @@ -448,8 +442,12 @@ func (process *Process) CloseStdin(ctx context.Context) (err error) {
}
}

process.stdin.Close()
process.stdin = nil
process.stdioLock.Lock()
defer process.stdioLock.Unlock()
if process.stdin != nil {
process.stdin.Close()
process.stdin = nil
}

return nil
}
Expand Down

0 comments on commit 641f8b8

Please # to comment.