Skip to content

Commit f152edc

Browse files
author
Mrunal Patel
committed
Merge pull request opencontainers#316 from cpuguy83/race_on_output_start_error
Fix for race from error on process start
2 parents 7f9864f + 7632c45 commit f152edc

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

libcontainer/integration/execin_test.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,23 @@ func TestExecInError(t *testing.T) {
133133
}()
134134
ok(t, err)
135135

136-
unexistent := &libcontainer.Process{
137-
Args: []string{"unexistent"},
138-
Env: standardEnvironment,
139-
}
140-
err = container.Start(unexistent)
141-
if err == nil {
142-
t.Fatal("Should be an error")
143-
}
144-
if !strings.Contains(err.Error(), "executable file not found") {
145-
t.Fatalf("Should be error about not found executable, got %s", err)
136+
for i := 0; i < 42; i++ {
137+
var out bytes.Buffer
138+
unexistent := &libcontainer.Process{
139+
Args: []string{"unexistent"},
140+
Env: standardEnvironment,
141+
Stdout: &out,
142+
}
143+
err = container.Start(unexistent)
144+
if err == nil {
145+
t.Fatal("Should be an error")
146+
}
147+
if !strings.Contains(err.Error(), "executable file not found") {
148+
t.Fatalf("Should be error about not found executable, got %s", err)
149+
}
150+
if !bytes.Contains(out.Bytes(), []byte("executable file not found")) {
151+
t.Fatalf("executable file not found error not delivered to stdio:\n%s", out.String())
152+
}
146153
}
147154
}
148155

libcontainer/process_linux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func (p *setnsProcess) start() (err error) {
8484
return newSystemError(err)
8585
}
8686
if ierr != nil {
87+
p.wait()
8788
return newSystemError(ierr)
8889
}
8990

0 commit comments

Comments
 (0)