Although it appears that posix_kill() is built into all modern versions of PHP, it actually requires the "process" extension. Otherwise, you get an "undefined function" error when you call it. You might try this to make your code (more) robust on Linux:
<?php
function send_signal(int $pid, int $sig_num) : bool {
if ( function_exists("posix_kill") ) return posix_kill($pid, $sig_num);
exec("/usr/bin/kill -s $sig_num $pid 2>&1", $junk, $return_code);
return ! $return_code;
}
?>
Yes, it works right when $sig_num = 0.