We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 103abed commit 8daa5c9Copy full SHA for 8daa5c9
pkg/utils/file.go
@@ -26,6 +26,15 @@ func ReadPidFile(pidFile string) (int, error) {
26
return int(pid), nil
27
}
28
29
+func WritePidFile(pidFile string, pid int) error {
30
+ if pid < 1 {
31
+ // We might be running as PID 1 when running docker-in-docker,
32
+ // but 0 or negative PIDs are not acceptable.
33
+ return fmt.Errorf("invalid negative PID %d", pid)
34
+ }
35
+ return os.WriteFile(pidFile, []byte(strconv.Itoa(pid)), 0o644)
36
+}
37
+
38
func FileExists(path string) (bool, error) {
39
_, err := os.Stat(path)
40
exists := false
0 commit comments