Cleanup open pipes if logging binary fails to start

Signed-off-by: Akshat Kumar <kshtku@amazon.com>
This commit is contained in:
Akshat Kumar
2020-09-06 10:29:40 -07:00
parent 4cc99e57a7
commit 61da6986c0
4 changed files with 51 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ package runtime
import (
"net/url"
"os"
"os/exec"
)
@@ -42,3 +43,11 @@ func NewBinaryCmd(binaryURI *url.URL, id, ns string) *exec.Cmd {
return cmd
}
// CloseFiles closes any files passed in.
// It it used for cleanup in the event of unexpected errors.
func CloseFiles(files ...*os.File) {
for _, file := range files {
file.Close()
}
}