Skip to content

Conversation

@vcfgv
Copy link
Collaborator

@vcfgv vcfgv commented Nov 20, 2025

📝 Pull Request Template

1. Related Issue

Closes # (issue number)

Type of Change (select one)

Bug Fix

3. Description

  • Intermediate Shell Process: Invoking subprocess.Popen with shell=True spawns an intermediate shell process (e.g., /bin/sh) to execute the command. The FastAPI application runs as a child process of this shell. Consequently, the process object returned by Popen references the shell's PID, not the application's PID.

  • Signal Propagation Failure: When a SIGINT (Ctrl+C) is issued, the signal is received by the shell. Most shells terminate immediately upon receiving this signal without forwarding it to their child processes.

  • Orphaned Process Creation: The shell terminates successfully, causing the parent Python script to conclude that the subprocess has ended. However, the underlying FastAPI process continues to run in the background as an orphan process, resulting in a process leak.

4. Testing

  • I have tested this locally.
  • I have updated or added relevant tests.

5. Checklist

@vcfgv vcfgv requested a review from hazeone November 20, 2025 05:49
@vcfgv vcfgv force-pushed the bugfix/launch-script-dangling-backend-process branch from b4130b5 to 1a28fd5 Compare November 20, 2025 06:18
@vcfgv vcfgv requested a review from su8su November 20, 2025 06:32
@su8su su8su merged commit 99261d3 into main Nov 20, 2025
3 checks passed
@su8su su8su deleted the bugfix/launch-script-dangling-backend-process branch November 20, 2025 06:33
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.

2 participants