MCPcopy Create free account
hub / github.com/Coooolfan/onlyboxes / enter_foreground_loop

Function enter_foreground_loop

scripts/install.py:623–642  ·  view source on GitHub ↗

Block forever, monitoring managed processes. Ctrl+C / SIGTERM triggers sys.exit() which fires the atexit cleanup handler.

()

Source from the content-addressed store, hash-verified

621
622
623def enter_foreground_loop() -> None:
624 """Block forever, monitoring managed processes. Ctrl+C / SIGTERM triggers
625 sys.exit() which fires the atexit cleanup handler."""
626
627 def _shutdown(signum, frame):
628 print(f"\n{_c('33', 'Shutting down...')}")
629 sys.exit(0)
630
631 signal.signal(signal.SIGINT, _shutdown)
632 signal.signal(signal.SIGTERM, _shutdown)
633
634 print(f"\n{_c('33', 'Services running in foreground. Press Ctrl+C to stop.')}")
635
636 while True:
637 for proc in _fg_processes:
638 ret = proc.poll()
639 if ret is not None:
640 print(f"\n{_c('31', 'A managed process exited unexpectedly')} (pid={proc.pid}, code={ret})")
641 sys.exit(1)
642 time.sleep(1)
643
644
645# ---------------------------------------------------------------------------

Callers 1

mainFunction · 0.85

Calls 1

_cFunction · 0.85

Tested by

no test coverage detected