charon: Ignore an existing PID file if it references ourself
If a daemon PID file references the process that does the check, it is safe to ignore it; no running process can have the same PID. While this is rather unlikely to get restarted with the same PID under normal conditions, it is quite common when running inside PID namespaced containers: If a container gets stopped and restarted with a PID file remaining, it is very likely that the PID namespace assigns the same PID to our service, as they are assigned sequentially starting from 1.
This commit is contained in:
parent
a7005e435b
commit
9655a3ffbc
|
@ -204,7 +204,7 @@ static bool check_pidfile()
|
||||||
}
|
}
|
||||||
fclose(pidfile);
|
fclose(pidfile);
|
||||||
pidfile = NULL;
|
pidfile = NULL;
|
||||||
if (pid && kill(pid, 0) == 0)
|
if (pid && pid != getpid() && kill(pid, 0) == 0)
|
||||||
{
|
{
|
||||||
DBG1(DBG_DMN, "charon already running ('"PID_FILE"' exists)");
|
DBG1(DBG_DMN, "charon already running ('"PID_FILE"' exists)");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in New Issue