unix/Daemon: move code to ReadPidFile()

This commit is contained in:
Max Kellermann
2015-08-15 16:39:52 +02:00
parent 28a0c46ca7
commit 567bf445bf
2 changed files with 18 additions and 12 deletions

View File

@@ -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