П О Р Т А Л                            
С Е Т Е В Ы Х                          
П Р О Е К Т О В                        
  
Поиск по сайту:
                                                 
Главная

О проекте

Web-мастеру
     HTML & JavaScript
     SSI
     Perl
     PHP
     XML & XSLT
     Unix Shell

MySQL

Безопасность

Хостинг

Другое








Самое читаемое:

Учебник PHP - "Для Чайника".
Просмотров 3498 раз(а).

Иллюстрированный самоучитель по созданию сайтов.
Просмотров 6101 раз(а).

Учебник HTML.
Просмотров 3264 раз(а).

Руководство по PHP5.
Просмотров 5485 раз(а).

Хостинг через призму DNS.
Просмотров 4121 раз(а).

Подборка текстов стандартных документов.
Просмотров 55763 раз(а).

Учебник PHP - Самоучитель
Просмотров 3078 раз(а).

Документация на MySQL (учебник & справочное руководство)
Просмотров 5414 раз(а).

Внешние атаки...
Просмотров 3821 раз(а).

Учебник PHP.
Просмотров 2817 раз(а).

SSI в примерах.
Просмотров 37453 раз(а).



 
 
| Добавить в избранное | Сделать стартовой | Помощь





Руководство по PHP
Пред. След.

pcntl_signal

(PHP 4 >= 4.1.0, PHP 5)

pcntl_signal -- Installs a signal handler

Description

bool pcntl_signal ( int signo, callback handle [, bool restart_syscalls] )

The pcntl_signal() function installs a new signal handler for the signal indicated by signo. The signal handler is set to handler which may be the name of a user created function, or either of the two global constants SIG_IGN or SIG_DFL. The optional restart_syscalls specifies whether system call restarting should be used when this signal arrives and defaults to TRUE.

Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.

Замечание: The optional restart_syscalls parameter became available in PHP 4.3.0.

Замечание: The ability to use an object method as a callback became available in PHP 4.3.0. Note that when you set a handler to an object method, that object's reference count is increased which makes it persist until you either change the handler to something else, or your script ends.

Пример 1. pcntl_signal() example

<?php
// tick use required as of PHP 4.3.0
declare(ticks = 1);

// signal handler function
function sig_handler($signo)
{

     switch (
$signo) {
         case
SIGTERM:
             
// handle shutdown tasks
             
exit;
             break;
         case
SIGHUP:
             
// handle restart tasks
             
break;
         case
SIGUSR1:
             echo
"Caught SIGUSR1...\n";
             break;
         default:
             
// handle all other signals
     
}

}

echo
"Installing signal handler...\n";

// setup signal handlers
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP,  "sig_handler");
pcntl_signal(SIGUSR1, "sig_handler");

// or use an object, available as of PHP 4.3.0
// pcntl_signal(SIGUSR1, array($obj, "do_something");

echo"Generating signal SIGTERM to self...\n";

// send SIGUSR1 to current process id
posix_kill(posix_getpid(), SIGUSR1);

echo
"Done\n"

?>

Замечание: As of PHP 4.3.0 PCNTL uses ticks as the signal handle callback mechanism, which is much faster than the previous mechanism. This change follows the same semantics as using "user ticks". You must use the declare() statement to specify the locations in your program where callbacks are allowed to occur for the signal handler to function properly (as used in the above example).

See also pcntl_fork() and pcntl_waitpid().



Если Вы не нашли что искали, то рекомендую воспользоваться поиском по сайту:
 





Copyright © 2005-2016 Project.Net.Ru