This commit is contained in:
2026-01-21 15:08:22 -08:00
parent 3c19109222
commit da2bff8cd4
4 changed files with 116 additions and 7 deletions

View File

@@ -696,16 +696,22 @@ def main():
action="store_true",
help="Shut down if parent process dies"
)
parser.add_argument(
"--parent-pid",
type=int,
default=None,
help="Explicit PID to monitor (defaults to the immediate parent process)",
)
args = parser.parse_args()
# Start monitor thread if requested
if args.monitor:
ppid = os.getppid()
if ppid > 1:
monitor_pid = args.parent_pid or os.getppid()
if monitor_pid > 1:
monitor_thread = threading.Thread(
target=monitor_parent,
args=(ppid, ),
args=(monitor_pid, ),
daemon=True
)
monitor_thread.start()