<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Constructs the EvChild watcher object</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.evchild.html">EvChild</a></div> <div class="next" style="text-align: right; float: right;"><a href="evchild.createstopped.html">EvChild::createStopped</a></div> <div class="up"><a href="class.evchild.html">EvChild</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="evchild.construct" class="refentry"> <div class="refnamediv"> <h1 class="refname">EvChild::__construct</h1> <p class="verinfo">(PECL ev >= 0.2.0)</p><p class="refpurpose"><span class="refname">EvChild::__construct</span> — <span class="dc-title">Constructs the EvChild watcher object</span></p> </div> <div class="refsect1 description" id="refsect1-evchild.construct-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><strong>EvChild::__construct</strong></span> ( <span class="methodparam"> <span class="type">int</span> <code class="parameter">$pid</code> </span> , <span class="methodparam"> <span class="type">bool</span> <code class="parameter">$trace</code> </span> , <span class="methodparam"> <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code> </span> [, <span class="methodparam"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$data</code> <span class="initializer"> = <strong><code>NULL</code></strong></span> </span> [, <span class="methodparam"> <span class="type">int</span> <code class="parameter">$priority</code> <span class="initializer"> = 0</span> </span> ]] )</div> <p class="para rdfs-comment"> Constructs the <a href="class.evchild.html" class="classname">EvChild</a> watcher object. </p> <p class="para"> Call the callback when a status change for process ID <em><code class="parameter">pid</code></em> (or any <em class="emphasis">PID</em> if <em><code class="parameter">pid</code></em> is <strong><code>0</code></strong> ) has been received(a status change happens when the process terminates or is killed, or, when <em><code class="parameter">trace</code></em> is <strong><code>TRUE</code></strong>, additionally when it is stopped or continued). In other words, when the process receives a <strong><code>SIGCHLD</code></strong> , <em class="emphasis">Ev</em> will fetch the outstanding exit/wait status for all changed/zombie children and call the callback. </p> <p class="para"> It is valid to install a child watcher after an <a href="class.evchild.html" class="classname">EvChild</a> has exited but before the event loop has started its next iteration. For example, first one calls <em>fork</em> , then the new child process might exit, and only then an <a href="class.evchild.html" class="classname">EvChild</a> watcher is installed in the parent for the new <em class="emphasis">PID</em> . </p> <p class="para"> You can access both exit/tracing status and <em><code class="parameter">pid</code></em> by using the <var class="varname"><var class="varname">rstatus</var></var> and <var class="varname"><var class="varname">rpid</var></var> properties of the watcher object. </p> <p class="para"> The number of <em class="emphasis">PID</em> watchers per <em class="emphasis">PID</em> is unlimited. All of them will be called. </p> <p class="para"> The <span class="methodname"><a href="evchild.createstopped.html" class="methodname">EvChild::createStopped()</a></span> method doesn't start(activate) the newly created watcher. </p> </div> <div class="refsect1 parameters" id="refsect1-evchild.construct-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <span class="term"> <em><code class="parameter">pid</code></em> </span> <dd> <p class="para"> Wait for status changes of process PID(or any process if PID is specified as <strong><code>0</code></strong> ). </p> </dd> </dt> <dt> <span class="term"> <em><code class="parameter">trace</code></em> </span> <dd> <p class="para"> If <strong><code>FALSE</code></strong>, only activate the watcher when the process terminates. Otherwise(<strong><code>TRUE</code></strong>) additionally activate the watcher when the process is stopped or continued. </p> </dd> </dt> <dt> <span class="term"> <em><code class="parameter">callback</code></em> </span> <dd> <p class="para"> See <a href="ev.watcher-callbacks.html" class="link">Watcher callbacks</a> . </p> </dd> </dt> <dt> <span class="term"> <em><code class="parameter">data</code></em> </span> <dd> <p class="para"> Custom data associated with the watcher. </p> </dd> </dt> <dt> <span class="term"> <em><code class="parameter">priority</code></em> </span> <dd> <p class="para"> <a href="class.ev.html#ev.constants.watcher-pri" class="link">Watcher priority</a> </p> </dd> </dt> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-evchild.construct-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns EvChild object on success. </p> </div> <div class="refsect1 seealso" id="refsect1-evchild.construct-seealso"> <h3 class="title">See Also</h3> <ul class="simplelist"> <li class="member"> <span class="methodname"><a href="evloop.child.html" class="methodname" rel="rdfs-seeAlso">EvLoop::child()</a> - Creates EvChild object associated with the current event loop</span> </li> </ul> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.evchild.html">EvChild</a></div> <div class="next" style="text-align: right; float: right;"><a href="evchild.createstopped.html">EvChild::createStopped</a></div> <div class="up"><a href="class.evchild.html">EvChild</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>