mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libct/cg.WriteCgroupProc: use fscommon.OpenFile
...and drop os.O_CREATE|os.O_TRUNC as those are definitely not needed. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -367,14 +367,14 @@ func WriteCgroupProc(dir string, pid int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroupProcessesFile, err := os.OpenFile(filepath.Join(dir, CgroupProcesses), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0700)
|
file, err := fscommon.OpenFile(dir, CgroupProcesses, os.O_WRONLY)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to write %v to %v: %v", pid, CgroupProcesses, err)
|
return fmt.Errorf("failed to write %v to %v: %v", pid, CgroupProcesses, err)
|
||||||
}
|
}
|
||||||
defer cgroupProcessesFile.Close()
|
defer file.Close()
|
||||||
|
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
_, err = cgroupProcessesFile.WriteString(strconv.Itoa(pid))
|
_, err = file.WriteString(strconv.Itoa(pid))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user