Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b7d18f9

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Process] Fix the fix for --enable-sigchild php
2 parents 7fe0a3b + cd94014 commit b7d18f9

File tree

2 files changed

+6
-29
lines changed

2 files changed

+6
-29
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ class Process
7575
private $latestSignal;
7676

7777
private static $sigchild;
78-
private static $posixSignals = array(
79-
1, // SIGHUP
80-
2, // SIGINT
81-
3, // SIGQUIT
82-
6, // SIGABRT
83-
14, // SIGALRM
84-
15, // SIGTERM
85-
);
8678

8779
/**
8880
* Exit codes translation table.
@@ -289,14 +281,9 @@ public function start($callback = null)
289281
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
290282
$descriptors[3] = array('pipe', 'w');
291283

292-
$commandline = '';
293-
foreach (self::$posixSignals as $s) {
294-
$commandline .= "trap 'echo s$s >&3' $s;";
295-
}
296-
297284
// See https://unix.stackexchange.com/questions/71205/background-process-pipe-input
298-
$commandline .= '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
299-
$commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo x$code >&3; exit $code';
285+
$commandline = '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
286+
$commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
300287

301288
// Workaround for the bug, when PTS functionality is enabled.
302289
// @see : https://bugs.php.net/69442
@@ -1353,19 +1340,9 @@ private function readPipes($blocking, $close)
13531340
$callback = $this->callback;
13541341
foreach ($result as $type => $data) {
13551342
if (3 === $type) {
1356-
foreach (explode("\n", substr($data, 0, -1)) as $data) {
1357-
if ('p' === $data[0]) {
1358-
$this->fallbackStatus['pid'] = (int) substr($data, 1);
1359-
} elseif ('s' === $data[0]) {
1360-
$this->fallbackStatus['signaled'] = true;
1361-
$this->fallbackStatus['exitcode'] = -1;
1362-
$this->fallbackStatus['termsig'] = (int) substr($data, 1);
1363-
} elseif ('x' === $data[0]) {
1364-
$this->fallbackStatus['running'] = false;
1365-
if (!isset($this->fallbackStatus['signaled'])) {
1366-
$this->fallbackStatus['exitcode'] = (int) substr($data, 1);
1367-
}
1368-
}
1343+
$this->fallbackStatus['running'] = false;
1344+
if (!isset($this->fallbackStatus['signaled'])) {
1345+
$this->fallbackStatus['exitcode'] = (int) $data;
13691346
}
13701347
} else {
13711348
$callback($type === self::STDOUT ? self::OUT : self::ERR, $data);

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ public function testRunProcessWithTimeout()
791791

792792
if ('\\' !== DIRECTORY_SEPARATOR) {
793793
// On Windows, timers are too transient
794-
$maxDuration = $timeout + Process::TIMEOUT_PRECISION;
794+
$maxDuration = $timeout + 2 * Process::TIMEOUT_PRECISION;
795795
$this->assertLessThan($maxDuration, $duration);
796796
}
797797

0 commit comments

Comments
 (0)