1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-27 04:44:56 +01:00

Skip cli_set_process_title inside phpdbg

This commit is contained in:
Niklas Keller 2017-06-17 20:46:22 +02:00
parent 39664d42d0
commit 4546ef8b1d
2 changed files with 10 additions and 6 deletions

View File

@ -4,7 +4,10 @@
use Amp\Parallel\Sync;
use Amp\Parallel\Worker;
@cli_set_process_title('amp-worker');
// Doesn't exist in phpdbg...
if (\function_exists('cli_set_process_title')) {
@cli_set_process_title('amp-worker');
}
// Redirect all output written using echo, print, printf, etc. to STDERR.
ob_start(function ($data) {
@ -17,7 +20,7 @@ ob_start(function ($data) {
dirname(__DIR__, 3) . '/autoload.php',
dirname(__DIR__) . '/vendor/autoload.php',
];
$autoloadPath = null;
foreach ($paths as $path) {
if (file_exists($path)) {
@ -25,12 +28,12 @@ ob_start(function ($data) {
break;
}
}
if ($autoloadPath === null) {
fwrite(STDERR, 'Could not locate autoload.php.');
exit(1);
}
require $autoloadPath;
})();

View File

@ -46,10 +46,11 @@ class ChannelParser extends Parser {
*/
private static function parser(callable $callback, callable $errorHandler): \Generator {
while (true) {
$data = \unpack("Cprefix/Llength", yield self::HEADER_LENGTH);
$header = yield self::HEADER_LENGTH;
$data = \unpack("Cprefix/Llength", $header);
if ($data["prefix"] !== 0) {
throw new ChannelException("Invalid header received");
throw new ChannelException("Invalid header received: " . \bin2hex($header));
}
$data = yield $data["length"];