Skip to content

Commit

Permalink
bug #54495 [Process] Don't call sigprocmask if there is no ignored si…
Browse files Browse the repository at this point in the history
…gnals (joelwurtz)

This PR was merged into the 7.1 branch.

Discussion
----------

[Process] Don't call sigprocmask if there is no ignored signals

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

It seems that passing an empty signal list makes an error on php 8.4 see https://github.com/symfony/symfony/actions/runs/8566954369/job/23477741854

This should fix this case

Commits
-------

3cf4e36 fix(process): don't call sigprocmask if there is no ignored signals
  • Loading branch information
nicolas-grekas committed Apr 5, 2024
2 parents cd0dbb8 + 3cf4e36 commit fd1d19e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Process/Process.php
Expand Up @@ -350,7 +350,7 @@ public function start(?callable $callback = null, array $env = []): void

$oldMask = [];

if (\function_exists('pcntl_sigprocmask')) {
if ($this->ignoredSignals && \function_exists('pcntl_sigprocmask')) {
// we block signals we want to ignore, as proc_open will use fork / posix_spawn which will copy the signal mask this allow to block
// signals in the child process
pcntl_sigprocmask(\SIG_BLOCK, $this->ignoredSignals, $oldMask);
Expand All @@ -359,7 +359,7 @@ public function start(?callable $callback = null, array $env = []): void
try {
$process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
} finally {
if (\function_exists('pcntl_sigprocmask')) {
if ($this->ignoredSignals && \function_exists('pcntl_sigprocmask')) {
// we restore the signal mask here to avoid any side effects
pcntl_sigprocmask(\SIG_SETMASK, $oldMask);
}
Expand Down

0 comments on commit fd1d19e

Please sign in to comment.