aboutsummaryrefslogtreecommitdiffstats
path: root/src/unix/PidFile.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/unix/PidFile.hxx')
-rw-r--r--src/unix/PidFile.hxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/unix/PidFile.hxx b/src/unix/PidFile.hxx
index 3c3d5ca21..a8af1e890 100644
--- a/src/unix/PidFile.hxx
+++ b/src/unix/PidFile.hxx
@@ -82,4 +82,20 @@ public:
}
};
+gcc_pure
+static inline pid_t
+ReadPidFile(Path path)
+{
+ FILE *fp = FOpen(path, PATH_LITERAL("r"));
+ if (fp == nullptr)
+ return -1;
+
+ int pid;
+ if (fscanf(fp, "%i", &pid) != 1)
+ pid = -1;
+
+ fclose(fp);
+ return pid;
+}
+
#endif