Skip to content

Commit 9b6f592

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [Process] Fix signaling/stopping logic on Windows Forward compatibility with AbstractLayout* 2.8 tests [Yaml] minor CS cleaning [Console] do not encode backslashes in console default description
2 parents 37ceef0 + 13fda1c commit 9b6f592

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

src/Symfony/Component/Console/Descriptor/TextDescriptor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ private function writeText($content, array $options = array())
236236
private function formatDefaultValue($default)
237237
{
238238
if (PHP_VERSION_ID < 50400) {
239-
return str_replace('\/', '/', json_encode($default));
239+
return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
240240
}
241241

242-
return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
242+
return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
243243
}
244244

245245
/**

src/Symfony/Component/Process/Process.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -775,36 +775,24 @@ public function getStatus()
775775
* Stops the process.
776776
*
777777
* @param int|float $timeout The timeout in seconds
778-
* @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL
778+
* @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9)
779779
*
780780
* @return int The exit-code of the process
781-
*
782-
* @throws RuntimeException if the process got signaled
783781
*/
784782
public function stop($timeout = 10, $signal = null)
785783
{
786784
$timeoutMicro = microtime(true) + $timeout;
787785
if ($this->isRunning()) {
788-
if ('\\' === DIRECTORY_SEPARATOR && !$this->isSigchildEnabled()) {
789-
exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode);
790-
if ($exitCode > 0) {
791-
throw new RuntimeException('Unable to kill the process');
792-
}
793-
}
794786
// given `SIGTERM` may not be defined and that `proc_terminate` uses the constant value and not the constant itself, we use the same here
795787
$this->doSignal(15, false);
796788
do {
797789
usleep(1000);
798790
} while ($this->isRunning() && microtime(true) < $timeoutMicro);
799791

800792
if ($this->isRunning() && !$this->isSigchildEnabled()) {
801-
if (null !== $signal || defined('SIGKILL')) {
802-
// avoid exception here :
803-
// process is supposed to be running, but it might have stop
804-
// just after this line.
805-
// in any case, let's silently discard the error, we can not do anything
806-
$this->doSignal($signal ?: SIGKILL, false);
807-
}
793+
// Avoid exception here: process is supposed to be running, but it might have stopped just
794+
// after this line. In any case, let's silently discard the error, we cannot do anything.
795+
$this->doSignal($signal ?: 9, false);
808796
}
809797
}
810798

@@ -1473,7 +1461,18 @@ private function doSignal($signal, $throwException)
14731461
return false;
14741462
}
14751463

1476-
if (true !== @proc_terminate($this->process, $signal)) {
1464+
if ('\\' === DIRECTORY_SEPARATOR) {
1465+
exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode);
1466+
if ($exitCode) {
1467+
if ($throwException) {
1468+
throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
1469+
}
1470+
1471+
return false;
1472+
}
1473+
}
1474+
1475+
if (true !== @proc_terminate($this->process, $signal) && '\\' !== DIRECTORY_SEPARATOR) {
14771476
if ($throwException) {
14781477
throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
14791478
}

src/Symfony/Component/Yaml/Parser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
347347
if (null === $indentation) {
348348
$newIndent = $this->getCurrentLineIndentation();
349349

350-
$unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem($this->currentLine);
350+
$unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem();
351351

352352
if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) {
353353
throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
@@ -373,7 +373,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
373373
return;
374374
}
375375

376-
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
376+
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem();
377377

378378
// Comments must not be removed inside a block scalar
379379
$removeCommentsPattern = '~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~';
@@ -386,7 +386,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
386386
$removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
387387
}
388388

389-
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine) && $newIndent === $indent) {
389+
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
390390
$this->moveToPreviousLine();
391391
break;
392392
}
@@ -700,7 +700,7 @@ private function isNextLineUnIndentedCollection()
700700
if (
701701
$this->getCurrentLineIndentation() == $currentIndentation
702702
&&
703-
$this->isStringUnIndentedCollectionItem($this->currentLine)
703+
$this->isStringUnIndentedCollectionItem()
704704
) {
705705
$ret = true;
706706
}

0 commit comments

Comments
 (0)