mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Wait for the reader fifo opening to block
In a rare case exec process may return before open gets called and the io will lock indefinitely. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
b599a07911
commit
2bebacef5f
1 changed files with 3 additions and 0 deletions
|
@ -79,7 +79,9 @@ func (r emptyReader) Read(b []byte) (int, error) {
|
||||||
|
|
||||||
func openReaderFromFifo(fn string) io.Reader {
|
func openReaderFromFifo(fn string) io.Reader {
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
c := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
|
close(c)
|
||||||
stdoutf, err := os.OpenFile(fn, syscall.O_RDONLY, 0)
|
stdoutf, err := os.OpenFile(fn, syscall.O_RDONLY, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.CloseWithError(err)
|
r.CloseWithError(err)
|
||||||
|
@ -90,6 +92,7 @@ func openReaderFromFifo(fn string) io.Reader {
|
||||||
w.Close()
|
w.Close()
|
||||||
stdoutf.Close()
|
stdoutf.Close()
|
||||||
}()
|
}()
|
||||||
|
<-c // wait for the goroutine to get scheduled and syscall to block
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue