Skip to content

Commit 9cf90fb

Browse files
ewgRanicolas-grekas
authored andcommitted
[2.3][Process] fix Proccess run with pts enabled
1 parent d46d725 commit 9cf90fb

File tree

1 file changed

+32
-19
lines changed

1 file changed

+32
-19
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ class Process
119119
/**
120120
* Constructor.
121121
*
122-
* @param string $commandline The command line to run
123-
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process
124-
* @param array|null $env The environment variables or null to inherit
125-
* @param string|null $stdin The STDIN content
126-
* @param integer|float|null $timeout The timeout in seconds or null to disable
127-
* @param array $options An array of options for proc_open
122+
* @param string $commandline The command line to run
123+
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process
124+
* @param array|null $env The environment variables or null to inherit
125+
* @param string|null $stdin The STDIN content
126+
* @param int|float|null $timeout The timeout in seconds or null to disable
127+
* @param array $options An array of options for proc_open
128128
*
129129
* @throws RuntimeException When proc_open is not installed
130130
*
@@ -184,7 +184,7 @@ public function __clone()
184184
* @param callback|null $callback A PHP callback to run whenever there is some
185185
* output available on STDOUT or STDERR
186186
*
187-
* @return integer The exit status code
187+
* @return int The exit status code
188188
*
189189
* @throws RuntimeException When process can't be launch or is stopped
190190
*
@@ -238,8 +238,20 @@ public function start($callback = null)
238238
}
239239
}
240240

241+
$ptsWorkaround = null;
242+
243+
if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
244+
// Workaround for the bug, when PTS functionality is enabled.
245+
// @see : https://bugs.php.net/69442
246+
$ptsWorkaround = fopen('php://fd/0', 'r');
247+
}
248+
241249
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
242250

251+
if ($ptsWorkaround) {
252+
fclose($ptsWorkaround);
253+
}
254+
243255
if (!is_resource($this->process)) {
244256
throw new RuntimeException('Unable to launch a new process.');
245257
}
@@ -287,7 +299,7 @@ public function restart($callback = null)
287299
*
288300
* @param callback|null $callback A valid PHP callback
289301
*
290-
* @return integer The exitcode of the process
302+
* @return int The exitcode of the process
291303
*
292304
* @throws RuntimeException When process timed out
293305
* @throws RuntimeException When process stopped after receiving signal
@@ -302,7 +314,7 @@ public function wait($callback = null)
302314
do {
303315
$this->checkTimeout();
304316
$running = defined('PHP_WINDOWS_VERSION_BUILD') ? $this->isRunning() : $this->processPipes->hasOpenHandles();
305-
$close = !defined('PHP_WINDOWS_VERSION_BUILD') || !$running;;
317+
$close = !defined('PHP_WINDOWS_VERSION_BUILD') || !$running;
306318
$this->readPipes(true, $close);
307319
} while ($running);
308320

@@ -324,7 +336,7 @@ public function wait($callback = null)
324336
/**
325337
* Returns the Pid (process identifier), if applicable.
326338
*
327-
* @return integer|null The process id if running, null otherwise
339+
* @return int|null The process id if running, null otherwise
328340
*
329341
* @throws RuntimeException In case --enable-sigchild is activated
330342
*/
@@ -342,7 +354,8 @@ public function getPid()
342354
/**
343355
* Sends a posix signal to the process.
344356
*
345-
* @param integer $signal A valid posix signal (see http://www.php.net/manual/en/pcntl.constants.php)
357+
* @param int $signal A valid posix signal (see http://www.php.net/manual/en/pcntl.constants.php)
358+
*
346359
* @return Process
347360
*
348361
* @throws LogicException In case the process is not running
@@ -434,7 +447,7 @@ public function getIncrementalErrorOutput()
434447
/**
435448
* Returns the exit code returned by the process.
436449
*
437-
* @return integer The exit status code
450+
* @return int The exit status code
438451
*
439452
* @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
440453
*
@@ -508,7 +521,7 @@ public function hasBeenSignaled()
508521
*
509522
* It is only meaningful if hasBeenSignaled() returns true.
510523
*
511-
* @return integer
524+
* @return int
512525
*
513526
* @throws RuntimeException In case --enable-sigchild is activated
514527
*
@@ -546,7 +559,7 @@ public function hasBeenStopped()
546559
*
547560
* It is only meaningful if hasBeenStopped() returns true.
548561
*
549-
* @return integer
562+
* @return int
550563
*
551564
* @api
552565
*/
@@ -612,10 +625,10 @@ public function getStatus()
612625
/**
613626
* Stops the process.
614627
*
615-
* @param integer|float $timeout The timeout in seconds
616-
* @param integer $signal A posix signal to send in case the process has not stop at timeout, default is SIGKILL
628+
* @param int|float $timeout The timeout in seconds
629+
* @param int $signal A posix signal to send in case the process has not stop at timeout, default is SIGKILL
617630
*
618-
* @return integer The exit-code of the process
631+
* @return int The exit-code of the process
619632
*
620633
* @throws RuntimeException if the process got signaled
621634
*/
@@ -704,7 +717,7 @@ public function getTimeout()
704717
*
705718
* To disable the timeout, set this value to null.
706719
*
707-
* @param integer|float|null $timeout The timeout in seconds
720+
* @param int|float|null $timeout The timeout in seconds
708721
*
709722
* @return self The current Process instance
710723
*
@@ -728,7 +741,7 @@ public function setTimeout($timeout)
728741
/**
729742
* Enables or disables the TTY mode.
730743
*
731-
* @param boolean $tty True to enabled and false to disable
744+
* @param bool $tty True to enabled and false to disable
732745
*
733746
* @return self The current Process instance
734747
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy