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 65501b7

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

File tree

3 files changed

+7
-123
lines changed
Filter options

3 files changed

+7
-123
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+
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
+6-60Lines changed: 6 additions & 60 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,17 +216,12 @@ 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
222219
* @throws ProcessFailedException if the process didn't terminate successfully
223220
*
224221
* @final since version 3.3
225222
*/
226223
public function mustRun(callable $callback = null, array $env = array())
227224
{
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.');
230-
}
231-
232225
if (0 !== $this->run($callback, $env)) {
233226
throw new ProcessFailedException($this);
234227
}
@@ -297,7 +290,7 @@ public function start(callable $callback = null, array $env = array())
297290
if ('\\' === DIRECTORY_SEPARATOR) {
298291
$options['bypass_shell'] = true;
299292
$commandline = $this->prepareWindowsCommandLine($commandline, $envBackup, $env);
300-
} elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
293+
} elseif (!$this->useFileHandles && $this->isSigchildEnabled()) {
301294
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
302295
$descriptors[3] = array('pipe', 'w');
303296

@@ -665,15 +658,9 @@ public function clearErrorOutput()
665658
* Returns the exit code returned by the process.
666659
*
667660
* @return null|int The exit status code, null if the Process is not terminated
668-
*
669-
* @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
670661
*/
671662
public function getExitCode()
672663
{
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.');
675-
}
676-
677664
$this->updateStatus(false);
678665

679666
return $this->exitcode;
@@ -716,17 +703,12 @@ public function isSuccessful()
716703
*
717704
* @return bool
718705
*
719-
* @throws RuntimeException In case --enable-sigchild is activated
720-
* @throws LogicException In case the process is not terminated
706+
* @throws LogicException In case the process is not terminated
721707
*/
722708
public function hasBeenSignaled()
723709
{
724710
$this->requireProcessIsTerminated(__FUNCTION__);
725711

726-
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
727-
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
728-
}
729-
730712
return $this->processInformation['signaled'];
731713
}
732714

@@ -744,7 +726,7 @@ public function getTermSignal()
744726
{
745727
$this->requireProcessIsTerminated(__FUNCTION__);
746728

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

@@ -1153,42 +1135,6 @@ public function setInput($input)
11531135
return $this;
11541136
}
11551137

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-
11921138
/**
11931139
* Sets whether environment variables will be inherited or not.
11941140
*
@@ -1322,7 +1268,7 @@ protected function updateStatus($blocking)
13221268

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

1325-
if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
1271+
if ($this->fallbackStatus && $this->isSigchildEnabled()) {
13261272
$this->processInformation = $this->fallbackStatus + $this->processInformation;
13271273
}
13281274

@@ -1431,7 +1377,7 @@ private function close()
14311377
if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
14321378
// if process has been signaled, no exitcode but a valid termsig, apply Unix convention
14331379
$this->exitcode = 128 + $this->processInformation['termsig'];
1434-
} elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
1380+
} elseif ($this->isSigchildEnabled()) {
14351381
$this->processInformation['signaled'] = true;
14361382
$this->processInformation['termsig'] = -1;
14371383
}
@@ -1496,7 +1442,7 @@ private function doSignal($signal, $throwException)
14961442
return false;
14971443
}
14981444
} else {
1499-
if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
1445+
if (!$this->isSigchildEnabled()) {
15001446
$ok = @proc_terminate($this->process, $signal);
15011447
} elseif (function_exists('posix_kill')) {
15021448
$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
-62Lines changed: 0 additions & 62 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,6 @@ public function testExitCodeCommandFailed()
420419
if ('\\' === DIRECTORY_SEPARATOR) {
421420
$this->markTestSkipped('Windows does not support POSIX exit code');
422421
}
423-
$this->skipIfNotEnhancedSigchild();
424422

425423
// such command run in bash return an exitcode 127
426424
$process = $this->getProcess('nonexistingcommandIhopeneversomeonewouldnameacommandlikethis');
@@ -455,7 +453,6 @@ public function testTTYCommandExitCode()
455453
if ('\\' === DIRECTORY_SEPARATOR) {
456454
$this->markTestSkipped('Windows does have /dev/tty support');
457455
}
458-
$this->skipIfNotEnhancedSigchild();
459456

460457
$process = $this->getProcess('echo "foo" >> /dev/null');
461458
$process->setTty(true);
@@ -481,8 +478,6 @@ public function testTTYInWindowsEnvironment()
481478

482479
public function testExitCodeTextIsNullWhenExitCodeIsNull()
483480
{
484-
$this->skipIfNotEnhancedSigchild();
485-
486481
$process = $this->getProcess('');
487482
$this->assertNull($process->getExitCodeText());
488483
}
@@ -503,8 +498,6 @@ public function testPTYCommand()
503498

504499
public function testMustRun()
505500
{
506-
$this->skipIfNotEnhancedSigchild();
507-
508501
$process = $this->getProcess('echo foo');
509502

510503
$this->assertSame($process, $process->mustRun());
@@ -513,8 +506,6 @@ public function testMustRun()
513506

514507
public function testSuccessfulMustRunHasCorrectExitCode()
515508
{
516-
$this->skipIfNotEnhancedSigchild();
517-
518509
$process = $this->getProcess('echo foo')->mustRun();
519510
$this->assertEquals(0, $process->getExitCode());
520511
}
@@ -524,16 +515,12 @@ public function testSuccessfulMustRunHasCorrectExitCode()
524515
*/
525516
public function testMustRunThrowsException()
526517
{
527-
$this->skipIfNotEnhancedSigchild();
528-
529518
$process = $this->getProcess('exit 1');
530519
$process->mustRun();
531520
}
532521

533522
public function testExitCodeText()
534523
{
535-
$this->skipIfNotEnhancedSigchild();
536-
537524
$process = $this->getProcess('');
538525
$r = new \ReflectionObject($process);
539526
$p = $r->getProperty('exitcode');
@@ -562,8 +549,6 @@ public function testUpdateStatus()
562549

563550
public function testGetExitCodeIsNullOnStart()
564551
{
565-
$this->skipIfNotEnhancedSigchild();
566-
567552
$process = $this->getProcessForCode('usleep(100000);');
568553
$this->assertNull($process->getExitCode());
569554
$process->start();
@@ -574,8 +559,6 @@ public function testGetExitCodeIsNullOnStart()
574559

575560
public function testGetExitCodeIsNullOnWhenStartingAgain()
576561
{
577-
$this->skipIfNotEnhancedSigchild();
578-
579562
$process = $this->getProcessForCode('usleep(100000);');
580563
$process->run();
581564
$this->assertEquals(0, $process->getExitCode());
@@ -587,8 +570,6 @@ public function testGetExitCodeIsNullOnWhenStartingAgain()
587570

588571
public function testGetExitCode()
589572
{
590-
$this->skipIfNotEnhancedSigchild();
591-
592573
$process = $this->getProcess('echo foo');
593574
$process->run();
594575
$this->assertSame(0, $process->getExitCode());
@@ -624,17 +605,13 @@ public function testStop()
624605

625606
public function testIsSuccessful()
626607
{
627-
$this->skipIfNotEnhancedSigchild();
628-
629608
$process = $this->getProcess('echo foo');
630609
$process->run();
631610
$this->assertTrue($process->isSuccessful());
632611
}
633612

634613
public function testIsSuccessfulOnlyAfterTerminated()
635614
{
636-
$this->skipIfNotEnhancedSigchild();
637-
638615
$process = $this->getProcessForCode('usleep(100000);');
639616
$process->start();
640617

@@ -647,8 +624,6 @@ public function testIsSuccessfulOnlyAfterTerminated()
647624

648625
public function testIsNotSuccessful()
649626
{
650-
$this->skipIfNotEnhancedSigchild();
651-
652627
$process = $this->getProcessForCode('throw new \Exception(\'BOUM\');');
653628
$process->run();
654629
$this->assertFalse($process->isSuccessful());
@@ -659,7 +634,6 @@ public function testProcessIsNotSignaled()
659634
if ('\\' === DIRECTORY_SEPARATOR) {
660635
$this->markTestSkipped('Windows does not support POSIX signals');
661636
}
662-
$this->skipIfNotEnhancedSigchild();
663637

664638
$process = $this->getProcess('echo foo');
665639
$process->run();
@@ -671,7 +645,6 @@ public function testProcessWithoutTermSignal()
671645
if ('\\' === DIRECTORY_SEPARATOR) {
672646
$this->markTestSkipped('Windows does not support POSIX signals');
673647
}
674-
$this->skipIfNotEnhancedSigchild();
675648

676649
$process = $this->getProcess('echo foo');
677650
$process->run();
@@ -683,7 +656,6 @@ public function testProcessIsSignaledIfStopped()
683656
if ('\\' === DIRECTORY_SEPARATOR) {
684657
$this->markTestSkipped('Windows does not support POSIX signals');
685658
}
686-
$this->skipIfNotEnhancedSigchild();
687659

688660
$process = $this->getProcessForCode('sleep(32);');
689661
$process->start();
@@ -701,7 +673,6 @@ public function testProcessThrowsExceptionWhenExternallySignaled()
701673
if (!function_exists('posix_kill')) {
702674
$this->markTestSkipped('Function posix_kill is required.');
703675
}
704-
$this->skipIfNotEnhancedSigchild(false);
705676

706677
$process = $this->getProcessForCode('sleep(32.1);');
707678
$process->start();
@@ -912,8 +883,6 @@ public function testSignal()
912883
*/
913884
public function testExitCodeIsAvailableAfterSignal()
914885
{
915-
$this->skipIfNotEnhancedSigchild();
916-
917886
$process = $this->getProcess('sleep 4');
918887
$process->start();
919888
$process->signal(SIGKILL);
@@ -1487,21 +1456,6 @@ private function getProcess($commandline, $cwd = null, array $env = null, $input
14871456
$process = new Process($commandline, $cwd, $env, $input, $timeout);
14881457
$process->inheritEnvironmentVariables();
14891458

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-
15051459
if (self::$process) {
15061460
self::$process->stop(0);
15071461
}
@@ -1516,22 +1470,6 @@ private function getProcessForCode($code, $cwd = null, array $env = null, $input
15161470
{
15171471
return $this->getProcess(array(self::$phpBin, '-r', $code), $cwd, $env, $input, $timeout);
15181472
}
1519-
1520-
private function skipIfNotEnhancedSigchild($expectException = true)
1521-
{
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-
}
1532-
}
1533-
}
1534-
}
15351473
}
15361474

15371475
class NonStringifiable

0 commit comments

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