diff --git a/openpilot/system/manager/process.py b/openpilot/system/manager/process.py index 43ea3f7306..e55f45e855 100644 --- a/openpilot/system/manager/process.py +++ b/openpilot/system/manager/process.py @@ -105,6 +105,12 @@ class ManagerProcess(ABC): return ret + def reap(self) -> None: + # a process that exited on its own is otherwise never restarted: start() early-returns while proc is + # set, and only stop() clears it. modeld dying on a bad eGPU load left it dead for the whole drive. + if self.proc is not None and self.proc.exitcode is not None: + self.stop() + def signal(self, sig: int) -> None: if self.proc is None: return @@ -145,6 +151,7 @@ class NativeProcess(ManagerProcess): # In case we only tried a non blocking stop we need to stop it before restarting if self.shutting_down: self.stop() + self.reap() if self.proc is not None: return @@ -169,6 +176,7 @@ class PythonProcess(ManagerProcess): # In case we only tried a non blocking stop we need to stop it before restarting if self.shutting_down: self.stop() + self.reap() if self.proc is not None: return