It might happen that we have a stale PID file, e.g. after a crash,
but some other process has taken the freed PID already.
import logging
-from os import kill # pylint: disable=[no-name-in-module]
+from os import kill, getppid # pylint: disable=[no-name-in-module]
from pathlib import Path
from typing import Any, Dict, Iterable, NoReturn, Optional, Union, cast
from xmlrpc.client import Fault, ServerProxy
pid = await _get_supervisord_pid(config)
if pid is None:
return False
- if not _is_process_runinng(pid):
+ if not _is_process_runinng(pid) or getppid() != pid:
supervisord_pid_file(config).unlink()
return False
return True