Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 194c2ce

Browse filesBrowse files
committed
Remove enhance sigchild compatibility
1 parent 7f52292 commit 194c2ce
Copy full SHA for 194c2ce

File tree

3 files changed

+44
-96
lines changed
Filter options

3 files changed

+44
-96
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ install:
158158
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
159159
tfold tty-group $PHPUNIT --group tty
160160
if [[ $PHP = $MIN_PHP ]]; then
161-
echo -e "1\\n0" | xargs -I{} bash -c "tfold src/Symfony/Component/Process.sigchild{} SYMFONY_DEPRECATIONS_HELPER=weak ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php ./phpunit --colors=always src/Symfony/Component/Process/"
161+
bash -c "tfold src/Symfony/Component/Process.sigchild SYMFONY_DEPRECATIONS_HELPER=weak php-$MIN_PHP/sapi/cli/php ./phpunit --colors=always src/Symfony/Component/Process/"
162162
fi
163163
fi
164164
}

‎src/Symfony/Component/Process/Process.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Process.php
+12-50Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class Process implements \IteratorAggregate
6464
private $outputDisabled = false;
6565
private $stdout;
6666
private $stderr;
67-
private $enhanceSigchildCompatibility;
6867
private $process;
6968
private $status = self::STATUS_READY;
7069
private $incrementalOutputOffset = 0;
@@ -165,7 +164,6 @@ public function __construct($commandline, $cwd = null, array $env = null, $input
165164
$this->setTimeout($timeout);
166165
$this->useFileHandles = '\\' === DIRECTORY_SEPARATOR;
167166
$this->pty = false;
168-
$this->enhanceSigchildCompatibility = '\\' !== DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
169167
}
170168

171169
public function __destruct()
@@ -218,15 +216,15 @@ public function run($callback = null, array $env = array())
218216
*
219217
* @return self
220218
*
221-
* @throws RuntimeException if PHP was compiled with --enable-sigchild and the enhanced sigchild compatibility mode is not enabled
219+
* @throws RuntimeException if PHP was compiled with --enable-sigchild
222220
* @throws ProcessFailedException if the process didn't terminate successfully
223221
*
224222
* @final since version 3.3
225223
*/
226224
public function mustRun(callable $callback = null, array $env = array())
227225
{
228-
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
229-
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
226+
if ($this->isSigchildEnabled()) {
227+
throw new RuntimeException('This PHP has been compiled with --enable-sigchild.');
230228
}
231229

232230
if (0 !== $this->run($callback, $env)) {
@@ -297,7 +295,7 @@ public function start(callable $callback = null, array $env = array())
297295
if ('\\' === DIRECTORY_SEPARATOR) {
298296
$options['bypass_shell'] = true;
299297
$commandline = $this->prepareWindowsCommandLine($commandline, $envBackup, $env);
300-
} elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
298+
} elseif (!$this->useFileHandles && $this->isSigchildEnabled()) {
301299
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
302300
$descriptors[3] = array('pipe', 'w');
303301

@@ -666,12 +664,12 @@ public function clearErrorOutput()
666664
*
667665
* @return null|int The exit status code, null if the Process is not terminated
668666
*
669-
* @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
667+
* @throws RuntimeException In case --enable-sigchild is activated
670668
*/
671669
public function getExitCode()
672670
{
673-
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
674-
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
671+
if ($this->isSigchildEnabled()) {
672+
throw new RuntimeException('This PHP has been compiled with --enable-sigchild.');
675673
}
676674

677675
$this->updateStatus(false);
@@ -723,7 +721,7 @@ public function hasBeenSignaled()
723721
{
724722
$this->requireProcessIsTerminated(__FUNCTION__);
725723

726-
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
724+
if ($this->isSigchildEnabled()) {
727725
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
728726
}
729727

@@ -744,7 +742,7 @@ public function getTermSignal()
744742
{
745743
$this->requireProcessIsTerminated(__FUNCTION__);
746744

747-
if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
745+
if ($this->isSigchildEnabled() && -1 === $this->processInformation['termsig']) {
748746
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
749747
}
750748

@@ -1153,42 +1151,6 @@ public function setInput($input)
11531151
return $this;
11541152
}
11551153

1156-
/**
1157-
* Returns whether sigchild compatibility mode is activated or not.
1158-
*
1159-
* @return bool
1160-
*
1161-
* @deprecated since version 3.3, to be removed in 4.0. Sigchild compatibility will always be enabled.
1162-
*/
1163-
public function getEnhanceSigchildCompatibility()
1164-
{
1165-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
1166-
1167-
return $this->enhanceSigchildCompatibility;
1168-
}
1169-
1170-
/**
1171-
* Activates sigchild compatibility mode.
1172-
*
1173-
* Sigchild compatibility mode is required to get the exit code and
1174-
* determine the success of a process when PHP has been compiled with
1175-
* the --enable-sigchild option
1176-
*
1177-
* @param bool $enhance
1178-
*
1179-
* @return self The current Process instance
1180-
*
1181-
* @deprecated since version 3.3, to be removed in 4.0.
1182-
*/
1183-
public function setEnhanceSigchildCompatibility($enhance)
1184-
{
1185-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED);
1186-
1187-
$this->enhanceSigchildCompatibility = (bool) $enhance;
1188-
1189-
return $this;
1190-
}
1191-
11921154
/**
11931155
* Sets whether environment variables will be inherited or not.
11941156
*
@@ -1322,7 +1284,7 @@ protected function updateStatus($blocking)
13221284

13231285
$this->readPipes($running && $blocking, '\\' !== DIRECTORY_SEPARATOR || !$running);
13241286

1325-
if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
1287+
if ($this->fallbackStatus && $this->isSigchildEnabled()) {
13261288
$this->processInformation = $this->fallbackStatus + $this->processInformation;
13271289
}
13281290

@@ -1431,7 +1393,7 @@ private function close()
14311393
if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
14321394
// if process has been signaled, no exitcode but a valid termsig, apply Unix convention
14331395
$this->exitcode = 128 + $this->processInformation['termsig'];
1434-
} elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
1396+
} elseif ($this->isSigchildEnabled()) {
14351397
$this->processInformation['signaled'] = true;
14361398
$this->processInformation['termsig'] = -1;
14371399
}
@@ -1496,7 +1458,7 @@ private function doSignal($signal, $throwException)
14961458
return false;
14971459
}
14981460
} else {
1499-
if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
1461+
if (!$this->isSigchildEnabled()) {
15001462
$ok = @proc_terminate($this->process, $signal);
15011463
} elseif (function_exists('posix_kill')) {
15021464
$ok = @posix_kill($pid, $signal);

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Tests/ProcessTest.php
+31-45Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class ProcessTest extends TestCase
2828
private static $phpBin;
2929
private static $process;
3030
private static $sigchild;
31-
private static $notEnhancedSigchild = false;
3231

3332
public static function setUpBeforeClass()
3433
{
@@ -420,7 +419,7 @@ public function testExitCodeCommandFailed()
420419
if ('\\' === DIRECTORY_SEPARATOR) {
421420
$this->markTestSkipped('Windows does not support POSIX exit code');
422421
}
423-
$this->skipIfNotEnhancedSigchild();
422+
$this->skipIfSigchildEnabled();
424423

425424
// such command run in bash return an exitcode 127
426425
$process = $this->getProcess('nonexistingcommandIhopeneversomeonewouldnameacommandlikethis');
@@ -455,7 +454,7 @@ public function testTTYCommandExitCode()
455454
if ('\\' === DIRECTORY_SEPARATOR) {
456455
$this->markTestSkipped('Windows does have /dev/tty support');
457456
}
458-
$this->skipIfNotEnhancedSigchild();
457+
$this->skipIfSigchildEnabled();
459458

460459
$process = $this->getProcess('echo "foo" >> /dev/null');
461460
$process->setTty(true);
@@ -481,7 +480,7 @@ public function testTTYInWindowsEnvironment()
481480

482481
public function testExitCodeTextIsNullWhenExitCodeIsNull()
483482
{
484-
$this->skipIfNotEnhancedSigchild();
483+
$this->skipIfSigchildEnabled();
485484

486485
$process = $this->getProcess('');
487486
$this->assertNull($process->getExitCodeText());
@@ -503,7 +502,7 @@ public function testPTYCommand()
503502

504503
public function testMustRun()
505504
{
506-
$this->skipIfNotEnhancedSigchild();
505+
$this->skipIfSigchildEnabled();
507506

508507
$process = $this->getProcess('echo foo');
509508

@@ -513,7 +512,7 @@ public function testMustRun()
513512

514513
public function testSuccessfulMustRunHasCorrectExitCode()
515514
{
516-
$this->skipIfNotEnhancedSigchild();
515+
$this->skipIfSigchildEnabled();
517516

518517
$process = $this->getProcess('echo foo')->mustRun();
519518
$this->assertEquals(0, $process->getExitCode());
@@ -524,15 +523,15 @@ public function testSuccessfulMustRunHasCorrectExitCode()
524523
*/
525524
public function testMustRunThrowsException()
526525
{
527-
$this->skipIfNotEnhancedSigchild();
526+
$this->skipIfSigchildEnabled();
528527

529528
$process = $this->getProcess('exit 1');
530529
$process->mustRun();
531530
}
532531

533532
public function testExitCodeText()
534533
{
535-
$this->skipIfNotEnhancedSigchild();
534+
$this->skipIfSigchildEnabled();
536535

537536
$process = $this->getProcess('');
538537
$r = new \ReflectionObject($process);
@@ -562,7 +561,7 @@ public function testUpdateStatus()
562561

563562
public function testGetExitCodeIsNullOnStart()
564563
{
565-
$this->skipIfNotEnhancedSigchild();
564+
$this->skipIfSigchildEnabled();
566565

567566
$process = $this->getProcessForCode('usleep(100000);');
568567
$this->assertNull($process->getExitCode());
@@ -574,7 +573,7 @@ public function testGetExitCodeIsNullOnStart()
574573

575574
public function testGetExitCodeIsNullOnWhenStartingAgain()
576575
{
577-
$this->skipIfNotEnhancedSigchild();
576+
$this->skipIfSigchildEnabled();
578577

579578
$process = $this->getProcessForCode('usleep(100000);');
580579
$process->run();
@@ -587,7 +586,7 @@ public function testGetExitCodeIsNullOnWhenStartingAgain()
587586

588587
public function testGetExitCode()
589588
{
590-
$this->skipIfNotEnhancedSigchild();
589+
$this->skipIfSigchildEnabled();
591590

592591
$process = $this->getProcess('echo foo');
593592
$process->run();
@@ -624,7 +623,7 @@ public function testStop()
624623

625624
public function testIsSuccessful()
626625
{
627-
$this->skipIfNotEnhancedSigchild();
626+
$this->skipIfSigchildEnabled();
628627

629628
$process = $this->getProcess('echo foo');
630629
$process->run();
@@ -633,7 +632,7 @@ public function testIsSuccessful()
633632

634633
public function testIsSuccessfulOnlyAfterTerminated()
635634
{
636-
$this->skipIfNotEnhancedSigchild();
635+
$this->skipIfSigchildEnabled();
637636

638637
$process = $this->getProcessForCode('usleep(100000);');
639638
$process->start();
@@ -647,7 +646,7 @@ public function testIsSuccessfulOnlyAfterTerminated()
647646

648647
public function testIsNotSuccessful()
649648
{
650-
$this->skipIfNotEnhancedSigchild();
649+
$this->skipIfSigchildEnabled();
651650

652651
$process = $this->getProcessForCode('throw new \Exception(\'BOUM\');');
653652
$process->run();
@@ -659,7 +658,7 @@ public function testProcessIsNotSignaled()
659658
if ('\\' === DIRECTORY_SEPARATOR) {
660659
$this->markTestSkipped('Windows does not support POSIX signals');
661660
}
662-
$this->skipIfNotEnhancedSigchild();
661+
$this->skipIfSigchildEnabled();
663662

664663
$process = $this->getProcess('echo foo');
665664
$process->run();
@@ -671,7 +670,7 @@ public function testProcessWithoutTermSignal()
671670
if ('\\' === DIRECTORY_SEPARATOR) {
672671
$this->markTestSkipped('Windows does not support POSIX signals');
673672
}
674-
$this->skipIfNotEnhancedSigchild();
673+
$this->skipIfSigchildEnabled();
675674

676675
$process = $this->getProcess('echo foo');
677676
$process->run();
@@ -683,7 +682,7 @@ public function testProcessIsSignaledIfStopped()
683682
if ('\\' === DIRECTORY_SEPARATOR) {
684683
$this->markTestSkipped('Windows does not support POSIX signals');
685684
}
686-
$this->skipIfNotEnhancedSigchild();
685+
$this->skipIfSigchildEnabled();
687686

688687
$process = $this->getProcessForCode('sleep(32);');
689688
$process->start();
@@ -701,7 +700,7 @@ public function testProcessThrowsExceptionWhenExternallySignaled()
701700
if (!function_exists('posix_kill')) {
702701
$this->markTestSkipped('Function posix_kill is required.');
703702
}
704-
$this->skipIfNotEnhancedSigchild(false);
703+
$this->skipIfSigchildEnabled(false);
705704

706705
$process = $this->getProcessForCode('sleep(32.1);');
707706
$process->start();
@@ -912,7 +911,7 @@ public function testSignal()
912911
*/
913912
public function testExitCodeIsAvailableAfterSignal()
914913
{
915-
$this->skipIfNotEnhancedSigchild();
914+
$this->skipIfSigchildEnabled();
916915

917916
$process = $this->getProcess('sleep 4');
918917
$process->start();
@@ -1487,21 +1486,6 @@ private function getProcess($commandline, $cwd = null, array $env = null, $input
14871486
$process = new Process($commandline, $cwd, $env, $input, $timeout);
14881487
$process->inheritEnvironmentVariables();
14891488

1490-
if (false !== $enhance = getenv('ENHANCE_SIGCHLD')) {
1491-
try {
1492-
$process->setEnhanceSigchildCompatibility(false);
1493-
$process->getExitCode();
1494-
$this->fail('ENHANCE_SIGCHLD must be used together with a sigchild-enabled PHP.');
1495-
} catch (RuntimeException $e) {
1496-
$this->assertSame('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.', $e->getMessage());
1497-
if ($enhance) {
1498-
$process->setEnhanceSigchildCompatibility(true);
1499-
} else {
1500-
self::$notEnhancedSigchild = true;
1501-
}
1502-
}
1503-
}
1504-
15051489
if (self::$process) {
15061490
self::$process->stop(0);
15071491
}
@@ -1517,19 +1501,21 @@ private function getProcessForCode($code, $cwd = null, array $env = null, $input
15171501
return $this->getProcess(array(self::$phpBin, '-r', $code), $cwd, $env, $input, $timeout);
15181502
}
15191503

1520-
private function skipIfNotEnhancedSigchild($expectException = true)
1504+
private function skipIfSigchildEnabled($expectException = true)
15211505
{
1522-
if (self::$sigchild) {
1523-
if (!$expectException) {
1524-
$this->markTestSkipped('PHP is compiled with --enable-sigchild.');
1525-
} elseif (self::$notEnhancedSigchild) {
1526-
if (method_exists($this, 'expectException')) {
1527-
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
1528-
$this->expectExceptionMessage('This PHP has been compiled with --enable-sigchild.');
1529-
} else {
1530-
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild.');
1531-
}
1506+
if (!self::$sigchild) {
1507+
return;
1508+
}
1509+
1510+
if ($expectException) {
1511+
if (method_exists($this, 'expectException')) {
1512+
$this->expectException('Symfony\Component\Process\Exception\RuntimeException');
1513+
$this->expectExceptionMessage('This PHP has been compiled with --enable-sigchild.');
1514+
} else {
1515+
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild.');
15321516
}
1517+
} else {
1518+
$this->markTestSkipped('PHP is compiled with --enable-sigchild.');
15331519
}
15341520
}
15351521
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.