Why doesn't php sleep work in the windows-subsystem-linux?

Viewed 178

The system is Ubuntu 20.04 of windows wsl. I install php by apt install php.The version of php is 7.4.

I type php -r "sleep(2);" in the linux shell. But it does not work,end immediately

1 Answers

There's a bug into WSL v1 and Ubuntu 20.04. Until the fix doesn't comes out, my work around was creating my own sleep function, as follow:

function waitForSec($sec) {
    $arr = [];
    $siginf = [];
    pcntl_sigtimedwait($arr,$siginf,$sec);
}

Cheers!!!!

Related