Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitd9b8d0c

Browse files
committed
bug#16753 [Process] Fix signaling/stopping logic on Windows (nicolas-grekas)
This PR was merged into the 2.3 branch.Discussion----------[Process] Fix signaling/stopping logic on Windows| Q | A| ------------- | ---| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | -| License | MIT| Doc PR | -Commits-------9afbea2 [Process] Fix signaling/stopping logic on Windows
2 parents52209db +9afbea2 commitd9b8d0c

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -647,36 +647,24 @@ public function getStatus()
647647
* Stops the process.
648648
*
649649
* @param int|float $timeout The timeout in seconds
650-
* @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL
650+
* @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9)
651651
*
652652
* @return int The exit-code of the process
653-
*
654-
* @throws RuntimeException if the process got signaled
655653
*/
656654
publicfunctionstop($timeout =10,$signal =null)
657655
{
658656
$timeoutMicro =microtime(true) +$timeout;
659657
if ($this->isRunning()) {
660-
if ('\\' ===DIRECTORY_SEPARATOR && !$this->isSigchildEnabled()) {
661-
exec(sprintf('taskkill /F /T /PID %d 2>&1',$this->getPid()),$output,$exitCode);
662-
if ($exitCode >0) {
663-
thrownewRuntimeException('Unable to kill the process');
664-
}
665-
}
666658
// given `SIGTERM` may not be defined and that `proc_terminate` uses the constant value and not the constant itself, we use the same here
667659
$this->doSignal(15,false);
668660
do {
669661
usleep(1000);
670662
}while ($this->isRunning() &&microtime(true) <$timeoutMicro);
671663

672664
if ($this->isRunning() && !$this->isSigchildEnabled()) {
673-
if (null !==$signal ||defined('SIGKILL')) {
674-
// avoid exception here :
675-
// process is supposed to be running, but it might have stop
676-
// just after this line.
677-
// in any case, let's silently discard the error, we can not do anything
678-
$this->doSignal($signal ?:SIGKILL,false);
679-
}
665+
// Avoid exception here: process is supposed to be running, but it might have stopped just
666+
// after this line. In any case, let's silently discard the error, we cannot do anything.
667+
$this->doSignal($signal ?:9,false);
680668
}
681669
}
682670

@@ -1200,7 +1188,18 @@ private function doSignal($signal, $throwException)
12001188
returnfalse;
12011189
}
12021190

1203-
if (true !== @proc_terminate($this->process,$signal)) {
1191+
if ('\\' ===DIRECTORY_SEPARATOR) {
1192+
exec(sprintf('taskkill /F /T /PID %d 2>&1',$this->getPid()),$output,$exitCode);
1193+
if ($exitCode) {
1194+
if ($throwException) {
1195+
thrownewRuntimeException(sprintf('Unable to kill the process (%s).',implode('',$output)));
1196+
}
1197+
1198+
returnfalse;
1199+
}
1200+
}
1201+
1202+
if (true !== @proc_terminate($this->process,$signal) &&'\\' !==DIRECTORY_SEPARATOR) {
12041203
if ($throwException) {
12051204
thrownewRuntimeException(sprintf('Error while sending signal `%s`.',$signal));
12061205
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp