fix: C-01 WebRTC policy value, C-02 scoped taskkill, C-04 preflight race, E-11 socket timeout, E-27 ban test dedup, full audit doc
This commit is contained in:
@@ -279,6 +279,9 @@ class BrowserSession:
|
||||
return True, f"Firefox started ({mode}, pid {pid})."
|
||||
|
||||
def stop(self, dispose: bool = False) -> tuple[bool, str]:
|
||||
# Capture our PID before clearing the handle
|
||||
launched_pid: int | None = self._proc.pid if self._proc else None
|
||||
|
||||
# Terminate the Popen handle if still alive
|
||||
if self._proc and self._proc.poll() is None:
|
||||
try:
|
||||
@@ -292,17 +295,19 @@ class BrowserSession:
|
||||
finally:
|
||||
self._proc = None
|
||||
|
||||
# Also kill any remaining firefox.exe processes (handles the
|
||||
# detached-child case where the parent already exited naturally)
|
||||
try:
|
||||
subprocess.run(
|
||||
["taskkill", "/F", "/IM", "firefox.exe"],
|
||||
capture_output=True,
|
||||
timeout=10,
|
||||
creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0x08000000),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
# Kill only the process tree we spawned (handles the detached-child
|
||||
# case where the launcher process already exited naturally).
|
||||
# /T kills the entire child tree; /PID scopes to our PID only.
|
||||
if launched_pid is not None:
|
||||
try:
|
||||
subprocess.run(
|
||||
["taskkill", "/F", "/T", "/PID", str(launched_pid)],
|
||||
capture_output=True,
|
||||
timeout=10,
|
||||
creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0x08000000),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self._proc = None
|
||||
if dispose and self._profile_path and self._profile_path.exists():
|
||||
|
||||
Reference in New Issue
Block a user