Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix timeout in Process::stop method
- The timeout is ten times more than set. - The timeout does not occurs, it is actually blocking until the process dies.
- Loading branch information
1 parent
7221d25
commit bec8ff1
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Symfony/Component/Process/Tests/NonStopableProcess.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/** | ||
* Runs a PHP script that can be stopped only with a SIGKILL (9) signal for 3 seconds | ||
* | ||
* @args duration Run this script with a custom duration | ||
* | ||
* @example `php NonStopableProcess.php 42` will run the script for 42 seconds | ||
*/ | ||
|
||
function handleSignal($signal) | ||
{ | ||
switch ($signal) { | ||
case SIGTERM: | ||
$name = 'SIGTERM'; | ||
break; | ||
case SIGINT: | ||
$name = 'SIGINT'; | ||
break; | ||
default: | ||
$name = $signal . ' (unknown)'; | ||
break; | ||
} | ||
|
||
echo "received signal $name\n"; | ||
} | ||
|
||
declare(ticks=1); | ||
pcntl_signal(SIGTERM, 'handleSignal'); | ||
pcntl_signal(SIGINT, 'handleSignal'); | ||
|
||
$duration = isset($argv[1]) ? (int) $argv[1] : 3; | ||
$start = microtime(true); | ||
|
||
while ($duration > (microtime(true) - $start)) { | ||
usleep(1000); | ||
} |