Merge pull request #53 from marji/master
refs #52: try to remove stale pid file instead of aborting.
This commit is contained in:
commit
0ca45b2bd2
1 changed files with 6 additions and 0 deletions
|
@ -55,6 +55,12 @@ int read_pid()
|
||||||
if(file != NULL) {
|
if(file != NULL) {
|
||||||
fscanf(file, "%d", &pid);
|
fscanf(file, "%d", &pid);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
if (kill(pid, 0) == -1 && errno == ESRCH)
|
||||||
|
{ /* a process with such a pid does not exist, remove the pid file */
|
||||||
|
if (remove(PROGRAM_PID) == 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue