mirror of
https://github.com/docker/compose.git
synced 2026-10-12 02:13:08 +00:00
fix: close serveDemo stdout pipe on read failure
Addresses docker-agent review on #14258 (discussion_r4092089046): when ReadString fails after Start() succeeds, the pipe read-end was leaked -- nothing else calls Wait() on this deliberately long-lived subprocess. Mirrors the existing close on the Start() failure path. Signed-off-by: Nicolas De Loof <[email protected]>
This commit is contained in:
committed by
Guillaume Lours
parent
0748fa6792
commit
bad7616c8f
@@ -265,6 +265,9 @@ func serveDemo(bindAddr string) (string, error) {
|
||||
addr, err := bufio.NewReader(stdout).ReadString('\n')
|
||||
watchdog.Stop()
|
||||
if err != nil {
|
||||
// the subprocess outlives this function so nothing else calls
|
||||
// Wait() to close the pipe's read end: release it here
|
||||
_ = stdout.Close()
|
||||
return "", fmt.Errorf("bind %s: endpoint did not come up: %w", bindAddr, err)
|
||||
}
|
||||
return addr, nil
|
||||
|
||||
Reference in New Issue
Block a user