INNER CODE UNIT · Python
run_forwarding_signals
pathwaycom/llm-app · serviette/indexer/main.py:35
def run_forwarding_signals(command: list[str], *, grace: float = _KILL_GRACE) -> int:
"""Run ``command`` to completion, forwarding SIGTERM/SIGINT to its whole
process group; returns its exit code.
``pathway spawn`` starts the worker processes as plain children and
installs no signal handlers of its own, so a SIGTERM delivered to *this*
process (``serviette up``, systemd, ``docker stop``) used to kill just
the Python waiting on it and leave the spawner and every worker running
— still writing to the store, still holding the DuckDB lock and the
inter-worker ports. The child gets its own session so a terminal Ctrl-C
is not delivered to it twice (once by the terminal, once forwarded);
whatever signal reaches us is sent to the child's group, which covers
the spawner and the workers alike, and escalates to SIGKILL after
``grace`` seconds.
"""
proc = subprocess.Popen(command, start_new_session=True)
forwarded: list[int] = []