<?php
declare(ticks = 1);
function a()
{
sleep(10);
echo "a finishi\n";
}
function b()
{
echo "Stop\n";
}
function c()
{
usleep(100000);
}
function sig()
{
throw new Exception;
}
try
{
pcntl_alarm(1);
pcntl_signal(SIGALRM, "sig");
a();
pcntl_alarm(0);
}
catch(Exception $e)
{
echo "timeout\n";
}
b();
a();
b();
原文地址:http://www.cnblogs.com/zhujiasheng/p/3993100.html