downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

pcntl_exec> <Süreç Denetim İşlevleri
[edit] Last updated: Fri, 23 Mar 2012

view this page in

pcntl_alarm

(PHP 4 >= 4.3.0, PHP 5)

pcntl_alarmBelli bir süre sonra SIGALRM sinyali gönderir

Açıklama

int pcntl_alarm ( int $saniye )

saniye ile belirtilen sürenin sonunda sürece bir SIGALRM sinyali gönderir. Yapılan her pcntl_alarm() çağrısı bir öncekini geçersiz kılar.

Değiştirgeler

saniye

Sinyal gönderilene kadar beklenecek süre. Sıfır belirtilirse hiçbir sinyal gönderilmez.

Dönen Değerler

Devreye girmeden geçersiz hale getirilmiş önceki çağrının süresini döndürür. Böyle bir çağrı yoksa 0 döner.



add a note add a note User Contributed Notes pcntl_alarm
thessoro at gmail dot com 20-Apr-2011 09:05
If your process uses SIGALRM and sleep() at the same time, the alarm set could make sleep() to return prematurely.

To avoid this and ensure your process waits a number of seconds you could use a function or class similar to this one:

<?php
class SleepWorkaroundForSIGALRM {
    private
$time;
    function
__construct($seconds) {
       
$this->time = time() + $seconds;
        while (
$this->time >= time()) {
           
sleep(1);
        }
    }   
?>
j at ukr-info dot net 20-Oct-2005 04:51
<?php
   
declare(ticks = 1);

    function
signal_handler($signal) {
        print
"Caught SIGALRM\n";
       
pcntl_alarm(5);
    }

   
pcntl_signal(SIGALRM, "signal_handler", true);
   
pcntl_alarm(5);

    for(;;) {
    }

?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites