8000 [Process] Properly close pipes after a Process::stop call · symfony/symfony@d84df4c · GitHub
[go: up one dir, main page]

Skip to content

Commit d84df4c

Browse files
committed
[Process] Properly close pipes after a Process::stop call
1 parent e6d983c commit d84df4c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,13 @@ public function stop($timeout = 10, $signal = null)
626626
$this->signal($signal ?: SIGKILL);
627627
}
628628
}
629+
}
629630

630-
$this->updateStatus(false);
631+
$this->updateStatus(false);
632+
if ($this->processInformation['running']) {
633+
$this->close();
631634
}
635+
632636
$this->status = self::STATUS_TERMINATED;
633637

634638
return $this->exitcode;

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,21 @@ public function testCheckTimeoutOnStartedProcess()
477477
$this->assertFalse($process->isSuccessful());
478478
}
479479

480+
public function testStartAfterATimeout()
481+
{
482+
$process = $this->getProcess('php -r "while(true) {echo \'\'; usleep(1000); }"');
483+
$process->setTimeout(0.1);
484+
try {
485+
$process->run();
486+
$this->fail('An exception should have been raised.');
487+
} catch (\Exception $e) {
488+
489+
}
490+
$process->start();
491+
usleep(10000);
492+
$process->stop();
493+
}
494+
480495
public function testGetPid()
481496
{
482497
$process = $this->getProcess('php -r "sleep(1);"');

0 commit comments

Comments
 (0)
0