mirror of
https://github.com/troglobit/finit.git
synced 2026-10-20 11:19:35 +00:00
New function pid_file_read(), returns PID from a pid file
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
9052248127
commit
f6372de6a9
2 files changed
+20
No files matched your search
@@ -109,6 +109,25 @@ char *pid_file(svc_t *svc)
|
||||
return pid_runpath(fn, path, sizeof(path));
|
||||
}
|
||||
|
||||
pid_t pid_file_read(const char *fn)
|
||||
{
|
||||
pid_t pid = 0;
|
||||
FILE *fp;
|
||||
char buf[42];
|
||||
|
||||
fp = fopen(fn, "r");
|
||||
if (!fp)
|
||||
return -1;
|
||||
|
||||
if (fgets(buf, sizeof(buf), fp)) {
|
||||
chomp(buf);
|
||||
pid = atoi(buf);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
int pid_file_create(svc_t *svc)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
Reference in new issue
Block a user