Skip to content

Commit 7f3c1df

Browse files
committed
fix(vminit): close stream connections with process io
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
1 parent 78564ac commit 7f3c1df

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

  • internal/vminit/process

internal/vminit/process/io.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,30 @@ type processIO struct {
6565
}
6666

6767
func (p *processIO) Close() error {
68+
var result []error
6869
if p.io != nil {
69-
return p.io.Close()
70+
if err := p.io.Close(); err != nil {
71+
result = append(result, err)
72+
}
7073
}
74+
// Close the stream connections too. For the "stream" scheme both p.io
75+
// (the runc pipes) and p.streams (the vsock conns to the host shim) are
76+
// set, so closing p.io alone leaves the streams open. On the normal exit
77+
// path the copyPipes goroutines close the streams themselves once the
78+
// runc pipes EOF, but if the exec process fails to start, copyPipes is
79+
// never reached and this Close is the only cleanup. Leaving the streams
80+
// open wedges the host shim's IO-shutdown (it waits for an EOF that never
81+
// comes) until its 30s timeout fires. Closing here propagates EOF
82+
// immediately. Streams already closed by copyPipes return ErrClosed,
83+
// which callers ignore.
7184
for i, s := range p.streams {
7285
if s != nil && (i != 2 || s != p.streams[1]) {
73-
s.Close()
86+
if err := s.Close(); err != nil {
87+
result = append(result, err)
88+
}
7489
}
7590
}
76-
return nil
91+
return errors.Join(result...)
7792
}
7893

7994
func (p *processIO) IO() runc.IO {

0 commit comments

Comments
 (0)