Files
vibemake-pcb-studio/backend/tools/child_exec.py
T

14 lines
458 B
Python

"""Keep native worker children from surviving a killed orchestration process."""
import ctypes
import os
import signal
import sys
parent = int(sys.argv[1])
if sys.platform.startswith('linux'):
if ctypes.CDLL(None).prctl(1, signal.SIGTERM, 0, 0, 0) != 0:
raise SystemExit('Could not set parent-death signal')
if os.getppid() != parent:
raise SystemExit('Orchestration process ended before child startup')
os.execvp(sys.argv[2], sys.argv[2:])