mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 16:15:49 +03:00
[GH-ISSUE #1251] restartSysCalls is not defined #517
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#517
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @gmponos on GitHub (Dec 10, 2018).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1251
On this line https://github.com/Seldaek/monolog/blob/master/src/Monolog/SignalHandler.php#L96 the
restartSyscallsis never defined.. I could not understand what the intention was in order to fix it 😞@Seldaek commented on GitHub (Dec 11, 2018):
Pretty sure it's a typo and should be
$this->signalRestartSyscallsas that one exists and is unused.@Seldaek commented on GitHub (Dec 11, 2018):
Ping @RGustBardon though - also this should be applied on 1.x AFAIK
@RGustBardon commented on GitHub (Dec 11, 2018):
@gmponos: Thank you for reporting the bug! As @Seldaek suggested, it should be
$this->signalRestartHandlers.Thank you for attempting to come up with a fix! The idea is as follows:
When registering a signal handler, the user can require calling the signal handler previously registered for this signal after the logging of the signal is done. This is what the
$callPreviousparameter of theregisterSignalHandlermethod is responsible for. Previous signal handlers are stored in thepreviousSignalHandlerproperty.Another parameter of the
registerSignalHandlermethod ($restartSyscalls) controls whether system calls should be restarted upon a signal (cf.usleepinSignalHandlerTest). These preferences are stored in thesignalRestartSyscallsproperty.Before PHP 7.1, it was not possible to get the current signal handler. Since PHP 7.1,
pcntl_signal_get_handlerreturns eitherSIG_DFL(the default system handler for a given signal),SIG_IGN(ignore the signal), or a function (previously registered usingpcntl_signal).If the user wishes to call the previous signal handler after the logging takes place and
pcntl_signal_get_handlerreturns a function, this can be done in a straightforward matter: a call to the previous handler will suffice. This is what happens at the very end ofhandleSignal. However, in cases the previous signal handler is unknown,handleSignalattempts to call the default signal handler (SIG_DFL) once it is done logging.Right before making such an attempt, the current signal handler is still the one used for logging. For this reason, the signal handler is temporarily substituted with the default one (the first call to the
pcntl_signalfunction at the end ofhandleSignal), the process sends the signal to itself (posix_kill), it dispatches the newly installed signal handler (pcntl_signal_dispatch), and finally restores the Monolog signal handler (the second call to thepcntl_signalfunction).The current units tests have not been able to identify the problem as they never call
registerSignalHandlerwith both$callPreviousand$restartSyscallsset totrue.@Seldaek: Thank you for bringing the bug to my attention! I have created two pull requests with the same fix (#1252 for the master branch and #1253 for the 1.x branch).
@Seldaek commented on GitHub (Dec 11, 2018):
Great, thanks for the fixes :)