@@ -30,16 +30,37 @@ func TestExecIn(t *testing.T) {
3030 // Execute a first process in the container
3131 stdinR , stdinW , err := os .Pipe ()
3232 ok (t , err )
33+ defer func () {
34+ _ = stdinR .Close ()
35+ _ = stdinW .Close ()
36+ }()
37+ stdoutR , stdoutW , err := os .Pipe ()
38+ ok (t , err )
39+ defer func () {
40+ _ = stdoutR .Close ()
41+ _ = stdoutW .Close ()
42+ }()
43+
44+ ch := waitStdOut (stdoutR )
3345 process := & libcontainer.Process {
34- Cwd : "/" ,
35- Args : []string {"cat" },
36- Env : standardEnvironment ,
37- Stdin : stdinR ,
38- Init : true ,
46+ Cwd : "/" ,
47+ Args : []string {"cat" , "/proc/self/cmdline" , "-" },
48+ Env : standardEnvironment ,
49+ Stdin : stdinR ,
50+ Stdout : stdoutW ,
51+ Init : true ,
3952 }
4053 err = container .Run (process )
41- _ = stdinR .Close ()
42- defer stdinW .Close () //nolint: errcheck
54+ defer func () {
55+ _ , _ = stdinW .Write ([]byte ("hello" ))
56+ _ = stdinW .Close ()
57+ if _ , err := process .Wait (); err != nil {
58+ t .Log (err )
59+ }
60+ }()
61+ ok (t , err )
62+
63+ err = <- ch
4364 ok (t , err )
4465
4566 buffers := newStdBuffers ()
@@ -55,8 +76,6 @@ func TestExecIn(t *testing.T) {
5576 err = container .Run (ps )
5677 ok (t , err )
5778 waitProcess (ps , t )
58- _ = stdinW .Close ()
59- waitProcess (process , t )
6079
6180 out := buffers .Stdout .String ()
6281 if ! strings .Contains (out , "cat" ) || ! strings .Contains (out , "ps" ) {
@@ -242,23 +261,39 @@ func TestExecInTTY(t *testing.T) {
242261 // Execute a first process in the container
243262 stdinR , stdinW , err := os .Pipe ()
244263 ok (t , err )
264+ defer func () {
265+ _ = stdinR .Close ()
266+ _ = stdinW .Close ()
267+ }()
268+ stdoutR , stdoutW , err := os .Pipe ()
269+ ok (t , err )
270+ defer func () {
271+ _ = stdoutR .Close ()
272+ _ = stdoutW .Close ()
273+ }()
274+
275+ ch := waitStdOut (stdoutR )
245276 process := & libcontainer.Process {
246- Cwd : "/" ,
247- Args : []string {"cat" },
248- Env : standardEnvironment ,
249- Stdin : stdinR ,
250- Init : true ,
277+ Cwd : "/" ,
278+ Args : []string {"cat" , "/proc/self/cmdline" , "-" },
279+ Env : standardEnvironment ,
280+ Stdin : stdinR ,
281+ Stdout : stdoutW ,
282+ Init : true ,
251283 }
252284 err = container .Run (process )
253- _ = stdinR .Close ()
254285 defer func () {
286+ _ , _ = stdinW .Write ([]byte ("hello" ))
255287 _ = stdinW .Close ()
256288 if _ , err := process .Wait (); err != nil {
257289 t .Log (err )
258290 }
259291 }()
260292 ok (t , err )
261293
294+ err = <- ch
295+ ok (t , err )
296+
262297 ps := & libcontainer.Process {
263298 Cwd : "/" ,
264299 Args : []string {"ps" },
0 commit comments