summaryrefslogtreecommitdiff
path: root/pkg/util
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/util')
-rw-r--r--pkg/util/utils.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index 91aba9fa7..a9aad657d 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -638,3 +638,18 @@ func ValidateSysctls(strSlice []string) (map[string]string, error) {
func DefaultContainerConfig() *config.Config {
return containerConfig
}
+
+func CreateCidFile(cidfile string, id string) error {
+ cidFile, err := OpenExclusiveFile(cidfile)
+ if err != nil {
+ if os.IsExist(err) {
+ return errors.Errorf("container id file exists. Ensure another container is not using it or delete %s", cidfile)
+ }
+ return errors.Errorf("error opening cidfile %s", cidfile)
+ }
+ if _, err = cidFile.WriteString(id); err != nil {
+ logrus.Error(err)
+ }
+ cidFile.Close()
+ return nil
+}