"""TS-03 — restore process-global signal handlers after tests.

Supervisor.__init__ installs SIGINT/SIGTERM handlers as a construction side
effect (supervisor.py:116-117). Without restoration, in-process Supervisor
construction in one test leaks handlers into later tests. This autouse fixture
snapshots + restores them around every test.
"""

from __future__ import annotations

import signal

import pytest


@pytest.fixture(autouse=True)
def _restore_signal_handlers():
    saved = {s: signal.getsignal(s) for s in (signal.SIGINT, signal.SIGTERM)}
    try:
        yield
    finally:
        for s, h in saved.items():
            signal.signal(s, h)
