Skip to content

fix(cgi): timeout 5s — kills frozen script, returns 504#20

Merged
byronlove111 merged 1 commit into
mainfrom
fix/cgi-timeout
Jun 17, 2026
Merged

fix(cgi): timeout 5s — kills frozen script, returns 504#20
byronlove111 merged 1 commit into
mainfrom
fix/cgi-timeout

Conversation

@byronlove111

Copy link
Copy Markdown
Collaborator

Problème

Un script CGI qui tourne indéfiniment bloquait le read() du parent → le serveur freezait sur cette connexion.

Fix

Remplace le read() bloquant par select() avec un timeout de 5 secondes :

  • Si le script répond dans les 5s → lecture normale
  • Si timeout → kill(pid, SIGKILL) + waitpid + 504 Gateway Timeout

Tests

  • Script www/cgi-bin/infinite.py (sleep 30s) → 504 en 5s confirmé
  • 14/14 tests passent (dont le nouveau cas timeout)

Made with Cursor

- Replace blocking read() with select()-based readOutputWithTimeout()
- Kill child process with SIGKILL on timeout, return 504 Gateway Timeout
- Add infinite.py test script and timeout unit test (14/14)
- Add demo_cgi.cpp for manual shell testing

Co-authored-by: Cursor <cursoragent@cursor.com>
@byronlove111 byronlove111 merged commit 8a46883 into main Jun 17, 2026
1 check passed
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