Repository navigation
[10.x] Add POSIX compliant cleanup to artisan serve - #49943
Merged
Merged
Conversation
Member
|
@Tofandel could you please add a full description to your PR and not just link to an issue? (See the template when you open PR's). Thanks! |
Contributor
|
You might be able to use the built in signal abstractions: https://laravel.com/docs/10.x/artisan#signal-handling |
Contributor
Author
|
@rojtjo Indeed it's much better, forgot about it |
Member
Contributor
Author
|
It would be the case if pcntl wasn't activated in any env I think I got a false sense of security using the wrapper, that it would only run with pcntl enabled, but I forgot that the constants would be evaluated even if the callback doesn't run A quick fix would be to wrap the A future improvement for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #49941
Description
When running
php artisan serveit creates a subprocess for the server, but it seems to simply forward all it's input to the subprocess which is only listening for Ctrl + C on the keyboard to close itself which in turn exits the parent, this is is not POSIX compliantAs such when we kill the
php artisan servecommand it doesn't do any cleanup itself and the subprocess keeps runningSteps To Reproduce
php artisan serveps auxand get the pid ofphp artisan servekill -SIGTINT $the_pidwhich should be equivalent to a Ctrl + C signalps auxand notice that the main process is gone but the subprocess is still thereThis is a big problem when spawning
php artisan servefrom within another program, because programs should only use signals to kill their offspringsWith this PR if pcntl is enabled (it's optional but recommended in composer) any termination signal will trigger the cleanup of the subprocess