mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-09 14:46:46 +02:00
Merge pull request #1252 from RGustBardon/rgb/fix-restart-syscalls-master
Fix the property for restarting syscalls (#1251)
This commit is contained in:
@@ -60,29 +60,23 @@ class SignalHandler
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleSignal($signo, array $siginfo = null)
|
public function handleSignal($signo, array $siginfo = null): void
|
||||||
{
|
{
|
||||||
static $signals = [];
|
static $signals = [];
|
||||||
|
|
||||||
if (!$signals && extension_loaded('pcntl')) {
|
if (!$signals && extension_loaded('pcntl')) {
|
||||||
$pcntl = new ReflectionExtension('pcntl');
|
$pcntl = new ReflectionExtension('pcntl');
|
||||||
$constants = $pcntl->getConstants();
|
// HHVM 3.24.2 returns an empty array.
|
||||||
if (!$constants) {
|
foreach ($pcntl->getConstants() ?: get_defined_constants(true)['Core'] as $name => $value) {
|
||||||
// HHVM 3.24.2 returns an empty array.
|
|
||||||
$constants = get_defined_constants(true);
|
|
||||||
$constants = $constants['Core'];
|
|
||||||
}
|
|
||||||
foreach ($constants as $name => $value) {
|
|
||||||
if (substr($name, 0, 3) === 'SIG' && $name[3] !== '_' && is_int($value)) {
|
if (substr($name, 0, 3) === 'SIG' && $name[3] !== '_' && is_int($value)) {
|
||||||
$signals[$value] = $name;
|
$signals[$value] = $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($constants);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$level = isset($this->signalLevelMap[$signo]) ? $this->signalLevelMap[$signo] : LogLevel::CRITICAL;
|
$level = $this->signalLevelMap[$signo] ?? LogLevel::CRITICAL;
|
||||||
$signal = isset($signals[$signo]) ? $signals[$signo] : $signo;
|
$signal = $signals[$signo] ?? $signo;
|
||||||
$context = isset($siginfo) ? $siginfo : [];
|
$context = $siginfo ?? [];
|
||||||
$this->logger->log($level, sprintf('Program received signal %s', $signal), $context);
|
$this->logger->log($level, sprintf('Program received signal %s', $signal), $context);
|
||||||
|
|
||||||
if (!isset($this->previousSignalHandler[$signo])) {
|
if (!isset($this->previousSignalHandler[$signo])) {
|
||||||
@@ -93,7 +87,7 @@ class SignalHandler
|
|||||||
if (extension_loaded('pcntl') && function_exists('pcntl_signal') && function_exists('pcntl_sigprocmask') && function_exists('pcntl_signal_dispatch')
|
if (extension_loaded('pcntl') && function_exists('pcntl_signal') && function_exists('pcntl_sigprocmask') && function_exists('pcntl_signal_dispatch')
|
||||||
&& extension_loaded('posix') && function_exists('posix_getpid') && function_exists('posix_kill')
|
&& extension_loaded('posix') && function_exists('posix_getpid') && function_exists('posix_kill')
|
||||||
) {
|
) {
|
||||||
$restartSyscalls = isset($this->restartSyscalls[$signo]) ? $this->restartSyscalls[$signo] : true;
|
$restartSyscalls = $this->signalRestartSyscalls[$signo] ?? true;
|
||||||
pcntl_signal($signo, SIG_DFL, $restartSyscalls);
|
pcntl_signal($signo, SIG_DFL, $restartSyscalls);
|
||||||
pcntl_sigprocmask(SIG_UNBLOCK, [$signo], $oldset);
|
pcntl_sigprocmask(SIG_UNBLOCK, [$signo], $oldset);
|
||||||
posix_kill(posix_getpid(), $signo);
|
posix_kill(posix_getpid(), $signo);
|
||||||
|
Reference in New Issue
Block a user