8000 minor #17118 [Process] Fix the fix for --enable-sigchild php (nicolas… · SCIF/symfony@774081c · GitHub
[go: up one dir, main page]

Skip to content

Commit 774081c

Browse files
minor symfony#17118 [Process] Fix the fix for --enable-sigchild php (nicolas-grekas)
This PR was merged into the 2.3 branch. Discussion ---------- [Process] Fix the fix for --enable-sigchild php | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - https://travis-ci.org/symfony/symfony/jobs/98471329#L2685 https://travis-ci.org/symfony/symfony/jobs/98470780#L2689 Commits ------- 088fcfe [Process] Fix the fix for --enable-sigchild php
2 parents 5517368 + 088fcfe commit 774081c

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
@@ -65,14 +65,6 @@ class Process
6565
private $latestSignal;
6666

6767
private static $sigchild;
68-
private static $posixSignals = array(
69-
1, // SIGHUP
70-
2, // SIGINT
71-
3, // SIGQUIT
72-
6, // SIGABRT
73-
14, // SIGALRM
74-
15, // SIGTERM
75-
);
7668

7769
/**
7870
* Exit codes translation table.
@@ -246,14 +238,9 @@ public function start($callback = null)
246238
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
247239
$descriptors[3] = array('pipe', 'w');
248240

249-
$commandline = '';
250-
foreach (self::$posixSignals as $s) {
251-
$commandline .= "trap 'echo s$s >&3' $s;";
252-
}
253-
254241
// See https://unix.stackexchange.com/questions/71205/background-process-pipe-input
255-
$commandline .= '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
256-
$commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo x$code >&3; exit $code';
242+
$commandline = '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
243+
$commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
257244

258245
// Workaround for the bug, when PTS functionality is enabled.
259246
// @see : https://bugs.php.net/69442
@@ -1086,19 +1073,9 @@ private function readPipes($blocking, $close)
10861073
$callback = $this->callback;
10871074
foreach ($result as $type => $data) {
10881075
if (3 === $type) {
1089-
foreach (explode("\n", substr($data, 0, -1)) as $data) {
1090-
if ('p' === $data[0]) {
1091-
$this->fallbackStatus['pid'] = (int) substr($data, 1);
1092-
} elseif ('s' === $data[0]) {
1093-
$this->fallbackStatus['signaled'] = true;
1094-
$this->fallbackStatus['exitcode'] = -1;
1095-
$this->fallbackStatus['termsig'] = (int) substr($data, 1);
1096-
} elseif ('x' === $data[0]) {
1097-
$this->fallbackStatus['running'] = false;
1098-
if (!isset($this->fallbackStatus['signaled'])) {
1099-
$this->fallbackStatus['exitcode'] = (int) substr($data, 1);
1100-
}
1101-
}
1076+
$this->fallbackStatus['running'] = false;
1077+
if (!isset($this->fallbackStatus['signaled'])) {
1078+
$this->fallbackStatus['exitcode'] = (int) $data;
11021079
}
11031080
} else {
11041081
$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
@@ -689,7 +689,7 @@ public function testRunProcessWithTimeout()
689689

690690
if ('\\' !== DIRECTORY_SEPARATOR) {
691691
// On Windows, timers are too transient
692-
$maxDuration = $timeout + Process::TIMEOUT_PRECISION;
692+
$maxDuration = $timeout + 2 * Process::TIMEOUT_PRECISION;
693693
$this->assertLessThan($maxDuration, $duration);
694694
}
695695

0 commit comments

Comments
 (0)
0