JoyCodeProxy icon indicating copy to clipboard operation
JoyCodeProxy copied to clipboard

fix(daemon): prevent fork bomb by filtering supervisor env variable

Open zhangrr opened this issue 5 months ago • 0 comments

Critical fix for infinite process spawning issue.

Root cause:

  • RunSupervisor was inheriting ALL parent environment variables when spawning child processes, including _JOYCODE_DAEMON_SUPERVISOR=1
  • This caused child processes to also run in supervisor mode instead of serve mode, creating an infinite recursive fork bomb

Fixes:

  1. Filter out supervisor env variable when creating child environment

    • Child processes now correctly run in serve mode, not supervisor mode
    • Prevents infinite process spawning
  2. Separate log files to prevent file conflicts

    • Supervisor logs to daemon.log
    • Child serve processes log to serve.log
    • Avoids file lock conflicts that caused child crashes
  3. Add strings package import for HasPrefix check

Testing: ✅ Only 1 supervisor + 1 child process run (no fork bomb) ✅ daemon start/stop/restart/status all work correctly ✅ Service endpoints accessible and functional ✅ Logs properly separated and viewable

zhangrr avatar Jun 16 '26 01:06 zhangrr