Skip to content

Conversation

@toffguy77
Copy link

Problem

After stopping or restarting the application, zombie processes remain because subprocess.Popen child processes are terminated but never reaped with wait().

Solution

Added wait() calls after terminate() in:

  • app/xray/core.py: XRayCore.stop() method
  • app/dashboard/__init__.py: run_dev() cleanup handler

The fix includes:

  1. Call wait(timeout=5) after terminate() to give the process time to exit gracefully
  2. If the process doesn't exit within 5 seconds, call kill() followed by wait() to force termination

Testing

  • Verified that xray process is properly reaped after stopping
  • Verified that npm dev process is properly reaped on application exit

When terminating subprocess, always call wait() to properly reap the
child process and prevent zombie processes. Added timeout handling
with fallback to SIGKILL if the process doesn't terminate gracefully.

Affected files:
- app/xray/core.py: XRayCore.stop() now waits for xray process
- app/dashboard/__init__.py: run_dev() cleanup now waits for npm process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant