Skip to content

Fix: Make PCNTL extension optional for StdioServerTransport #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2025

Conversation

CodeWithKyrian
Copy link
Contributor

This PR fixes crashes when using StdioServerTransport in environments where the PCNTL extension isn't available.

Changes:

  • Signal handling now uses try/catch to gracefully handle missing signal support
  • Added ext-pcntl to composer.json suggest block for StreamSelectLoop users
  • Transport continues to work normally without signals since STDIN close still triggers shutdown

Why this works:

  • UV loop and other implementations handle signals natively without PCNTL
  • Signal handling is just a convenience - main termination mechanism remains intact

Closes #44

Signal handling now gracefully degrades when PCNTL extension is unavailable or the event loop doesn't support signals. The transport continues to work normally since termination also happens when STDIN closes.
@CodeWithKyrian CodeWithKyrian merged commit 37b40d5 into main Jul 12, 2025
8 checks passed
@CodeWithKyrian CodeWithKyrian deleted the fix/optional-pcntl-extension-stdio-transport branch July 12, 2025 22:19
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.

Undefined constant "PhpMcp\Server\Transports\SIGTERM"
1 participant