Merge pull request #652 from Praveensenpai/fix/xvfb-zombie-cleanup

fix: kill Xvfb with SIGKILL and clean up X11 lock/socket files
This commit is contained in:
daijro
2026-07-11 09:59:37 -05:00
committed by GitHub
+13 -6
View File
@@ -1,4 +1,5 @@
import os
import signal
import select
import subprocess # nosec
import time
@@ -115,14 +116,20 @@ class VirtualDisplay:
if self.proc and self.proc.poll() is None:
if self.debug:
print("Terminating virtual display:", self._display)
self.proc.terminate()
try:
self.proc.send_signal(signal.SIGKILL)
self.proc.wait(timeout=5)
except subprocess.TimeoutExpired:
if self.debug:
print("Xvfb did not exit in time, killing forcefully")
self.proc.kill()
self.proc.wait()
except Exception:
pass
try:
os.remove(f"/tmp/.X{self._display}-lock")
except FileNotFoundError:
pass
try:
os.remove(f"/tmp/.X11-unix/X{self._display}")
except FileNotFoundError:
pass
self.proc = None
@staticmethod
def _assert_linux() -> None: