Use StdinPipe to ensure pipe is properly closed after startup
Fixes #23686
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
... | ... |
@@ -32,12 +32,6 @@ type mountOptions struct { |
32 | 32 |
} |
33 | 33 |
|
34 | 34 |
func mountFrom(dir, device, target, mType, label string) error { |
35 |
- |
|
36 |
- r, w, err := os.Pipe() |
|
37 |
- if err != nil { |
|
38 |
- return fmt.Errorf("mountfrom pipe failure: %v", err) |
|
39 |
- } |
|
40 |
- |
|
41 | 35 |
options := &mountOptions{ |
42 | 36 |
Device: device, |
43 | 37 |
Target: target, |
... | ... |
@@ -47,7 +41,10 @@ func mountFrom(dir, device, target, mType, label string) error { |
47 | 47 |
} |
48 | 48 |
|
49 | 49 |
cmd := reexec.Command("docker-mountfrom", dir) |
50 |
- cmd.Stdin = r |
|
50 |
+ w, err := cmd.StdinPipe() |
|
51 |
+ if err != nil { |
|
52 |
+ return fmt.Errorf("mountfrom error on pipe creation: %v", err) |
|
53 |
+ } |
|
51 | 54 |
|
52 | 55 |
output := bytes.NewBuffer(nil) |
53 | 56 |
cmd.Stdout = output |