HighSpeaker/timeout.php

29 lines
300 B
PHP
Raw Normal View History

<?php
declare(ticks = 1);
function a()
{
}
function b()
{
echo "Stop\n";
}
function c()
{
usleep(100000);
}
function sig()
{
throw new Exception;
}
try
{
pcntl_alarm(5);
pcntl_signal(SIGALRM, "sig");
a();
pcntl_alarm(0);
}
catch(Exception $e)
{
echo "timeout\n";
}