Skip to content

Commit

Permalink
bug #36141 Prevent warning in proc_open() (BenMorel)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 3.4 branch.

Discussion
----------

Prevent warning in proc_open()

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | none
| License       | MIT
| Doc PR        | none

In addition to returning `false`, `proc_open()` triggers a warning when it fails. For example:

>  Warning: proc_open(): fork failed - Cannot allocate memory

When using the `ErrorHandler`, the warning gets promoted to an exception, and the next line, `if (! is_resource(...`, is not executed. This mutes the warning and ensures that the next line is always executed and the proper exception is thrown.

Commits
-------

d43833a Prevent warning in proc_open()
  • Loading branch information
fabpot committed Mar 20, 2020
2 parents 5f364af + d43833a commit 98da88f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Process/Process.php
Expand Up @@ -336,7 +336,7 @@ public function start(callable $callback = null/*, array $env = [*/)
@trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behavior is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
}

$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
$this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);

if (!\is_resource($this->process)) {
throw new RuntimeException('Unable to launch a new process.');
Expand Down

0 comments on commit 98da88f

Please sign in to comment.