fix(bridge): close stdout/stderr pipes on exec timeout to prevent stream hang (#351)

This commit is contained in:
EYHN
2026-04-09 21:43:11 +08:00
committed by GitHub
parent d3bf6bc90a
commit f2fa845e16
+11
View File
@@ -388,6 +388,17 @@ func execPipe(stream pb.ContainerService_ExecServer, firstMsg *pb.ExecInput) err
return status.Errorf(codes.Internal, "start: %v", err)
}
// When the context deadline fires, exec.CommandContext sends SIGKILL to the
// main process. However, child processes may still hold the stdout/stderr
// pipe file descriptors open, causing streamPipe's Read to block forever.
// Closing the pipes here unblocks those reads so the function can proceed
// to cmd.Wait and send the EXIT message back to the client.
go func() {
<-ctx.Done()
_ = stdoutPipe.Close()
_ = stderrPipe.Close()
}()
go func() {
for {
msg, recvErr := stream.Recv()