Skip to content

Commit

Permalink
Merge pull request #53 from marji/master
Browse files Browse the repository at this point in the history
refs #52: try to remove stale pid file instead of aborting.
  • Loading branch information
Daniel Graziotin committed Jan 29, 2015
2 parents b5f8bdd + 63c95fd commit 0ca45b2
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 0ca45b2

Please sign in to comment.