mirror of
https://github.com/curl/curl.git
synced 2026-08-25 00:13:34 +03:00
refactor some code out to write_pidfile() in util.c
This commit is contained in:
parent
9682c2037e
commit
0d09f342c4
5 changed files with 32 additions and 52 deletions
|
|
@ -222,3 +222,19 @@ int wait_ms(int timeout_ms)
|
|||
return r;
|
||||
}
|
||||
|
||||
bool write_pidfile(const char *filename)
|
||||
{
|
||||
FILE *pidfile;
|
||||
long pid;
|
||||
|
||||
pid = (long)getpid();
|
||||
pidfile = fopen(filename, "w");
|
||||
if(!pidfile) {
|
||||
logmsg("Couldn't write pid file: %s %s", filename, strerror(ERRNO));
|
||||
return FALSE;
|
||||
}
|
||||
fprintf(pidfile, "%ld\n", pid);
|
||||
fclose(pidfile);
|
||||
logmsg("Wrote pid %ld to %s", pid, filename);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue