PHP 忒聊 綴豖 ヶ輛 pcntl_signal (PHP 4 = 4.1.0) Description 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. pcntl_signal() returns TRUE on success or FALSE on failure. 瞰赽 1. pcntl_signal() Example ?php // signal handler function function sig_handler($signo) {switch($signo) {case SIGTERM: // handle shutdown tasks exit; break; case SIGHUP: // handle restart tasks break; case SIGUSR1: print "Caught SIGUSR1...\n"; break; default: // handle all other signals}} print "Installing signal handler...\n"; // setup signal handlers pcntl_signal(SIGTERM, "sig_handler"); pcntl_signal(SIGHUP, "sig_handler"); pcntl_signal(SIGUSR1, "sig_handler"); print "Generating signal SIGTERM to self...\n"; // send SIGUSR1 to current process id posix_kill(posix_getpid(), SIGUSR1); print "Done\n"? See also pcntl_fork() and pcntl_waitpid(). 綴豖 れ萸 ヶ輛 pcntl_fork 奻珨撰 pcntl_waitpid