Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > a34ed6838d4b29d38abd504392a4a797 > files > 2043

php-manual-es-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>pcntl_signal</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Manual de PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Process Control Functions"
HREF="ref.pcntl.html"><LINK
REL="PREVIOUS"
TITLE="pcntl_fork"
HREF="function.pcntl-fork.html"><LINK
REL="NEXT"
TITLE="pcntl_waitpid"
HREF="function.pcntl-waitpid.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Manual de PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.pcntl-fork.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.pcntl-waitpid.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.pcntl-signal"
></A
>pcntl_signal</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN65314"
></A
><P
>    (PHP 4 &#62;= 4.1.0)</P
>pcntl_signal&nbsp;--&nbsp;Installs a signal handler</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN65317"
></A
><H2
>Description</H2
>bool <B
CLASS="methodname"
>pcntl_signal</B
> ( int signo, mixed handle [, bool restart_syscalls])<BR
></BR
><P
>&#13;    The <B
CLASS="function"
>pcntl_signal()</B
> function installs a new
    signal handler for the signal indicated by
    <TT
CLASS="parameter"
><I
>signo</I
></TT
>.  The signal handler is set to
    <TT
CLASS="parameter"
><I
>handler</I
></TT
> which may be the name of a user
    created function, or either of the two global constants SIG_IGN
    or SIG_DFL.  The optional <TT
CLASS="parameter"
><I
>restart_syscalls</I
></TT
> 
    specifies whether system call restarting should be used when this 
    signal arrives and defaults to <TT
CLASS="constant"
><B
>TRUE</B
></TT
>.
   </P
><P
>&#13;    Devuelve <TT
CLASS="constant"
><B
>TRUE</B
></TT
> si todo fue bien, <TT
CLASS="constant"
><B
>FALSE</B
></TT
> en caso de fallo.
   </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
     The optional <TT
CLASS="parameter"
><I
>restart_syscalls</I
></TT
> parameter became
     available in PHP 4.3.0.
    </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
     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.
    </P
></BLOCKQUOTE
></DIV
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN65345"
></A
><P
><B
>Ejemplo 1. <B
CLASS="function"
>pcntl_signal()</B
> Example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?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:
             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");

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

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

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

print "Done\n"

?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;    See also <A
HREF="function.pcntl-fork.html"
><B
CLASS="function"
>pcntl_fork()</B
></A
> and
    <A
HREF="function.pcntl-waitpid.html"
><B
CLASS="function"
>pcntl_waitpid()</B
></A
>.
   </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.pcntl-fork.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Inicio</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.pcntl-waitpid.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>pcntl_fork</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.pcntl.html"
ACCESSKEY="U"
>Subir</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>pcntl_waitpid</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>