Skip to content

Commit

Permalink
refs #52: try to remove stale pid file instead of aborting.
Browse files Browse the repository at this point in the history
  • Loading branch information
marji committed Jan 14, 2015
1 parent b5f8bdd commit 63c95fd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ int read_pid()
if(file != NULL) {
fscanf(file, "%d", &pid);
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;
}

Expand Down

0 comments on commit 63c95fd

Please sign in to comment.