mirror of
https://github.com/daijro/camoufox.git
synced 2026-08-19 16:00:59 +00:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user