Fix fd leak of shim log

Open shim v2 log with the flag `O_RDWR` will cause the `Read()` block
forever even if the pipe has been closed on the shim side. Then the
`io.Copy()` would never return and lead to a fd leak.
Fix typo when closing shim v1 log which causes the `stdouLog` leak.
Update `numPipes` function in test case to get the opened FIFO
correctly.

Signed-off-by: Li Yuxuan <liyuxuan04@baidu.com>
This commit is contained in:
Li Yuxuan
2019-05-08 13:26:22 +08:00
parent d68b593de4
commit cf6e008542
3 changed files with 4 additions and 4 deletions

View File

@@ -98,9 +98,9 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
cmd.Wait()
exitHandler()
if stdoutLog != nil {
stderrLog.Close()
stdoutLog.Close()
}
if stdoutLog != nil {
if stderrLog != nil {
stderrLog.Close()
}
}()