I have the simplest Swoole code, which sleeps for a second and prints "Run task" message to the screen.
<?php
namespace Tests\Util;
use PHPUnit\Framework\TestCase;
class MultiprocessingTest extends TestCase
{
public function testProcess(): void
{
$t = new \Swoole\Process(function ($process) {
sleep(1);
echo "Run task\n";
}, false);
$t->start();
echo "Start main process!\n";
}
}
The problem is that it hangs forever. But if I remove sleep(1), it runs and exits as expected. What is wrong with that?