Skip to content

Fix PTY resource leaks, child lifecycle and integration coverage - #1

Merged
croustibat merged 3 commits into
mainfrom
fix/session-lifecycle-reliability
Sep 8, 2026
Merged

croustibat merged 3 commits into
mainfrom
fix/session-lifecycle-reliability

Conversation

@croustibat

@croustibat croustibat commented Sep 8, 2026 •

Copy link
Copy Markdown
Owner

Closing a session previously left its original PTY master open, and failed executable resolution leaked both master and slave descriptors. This prevented the expected hangup and accumulated resources in long-running CLI processes.

This change closes both owned master descriptors, makes cleanup idempotent, and closes inherited php-pty sessions in newly forked children. It validates executable paths, working directories and terminal dimensions before allocation, preserves executable symlinks, and prevents failed child setup/exec from running inherited PHP shutdown callbacks.

Child status handling now retries interrupted waits, preserves unknown statuses when another manager has reaped the child, and uses monotonic deadlines. Invalid timeouts are rejected. The README documents short writes, wait results and explicit process cleanup.

Validation:

  • 45 integration tests / 172 assertions pass locally on PHP 8.5.8, macOS arm64.
  • Regression coverage includes descriptor counts, SIGHUP, multiple simultaneous sessions, repeated cleanup, externally closed streams, interrupted waits, executable symlinks, child cwd/arguments/environment, and failed exec callbacks.
  • Saturation tests resume a partial write and verify the complete payload's length and SHA-256 in the child; round-trip tests no longer accept terminal echo as proof.
  • PHPStan level 6, Pint and Composer validation pass. Analysis-only FFI declarations retain checks for unknown properties and incompatible field types.
  • CI now covers PHP 8.2–8.5 on Linux and macOS, explicitly requires arm64 on macOS, and adds static analysis and style checks.

@croustibat
croustibat merged commit e7e634c into main Sep 8, 2026
9 checks passed
@croustibat
croustibat deleted the fix/session-lifecycle-reliability branch September 8, 2026 11:38
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