<?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> <refentry xml:id="function.sapi-windows-generate-ctrl-event" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>sapi_windows_generate_ctrl_event</refname> <refpurpose>Send a CTRL event to another process</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>sapi_windows_generate_ctrl_event</methodname> <methodparam><type>int</type><parameter>event</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>pid</parameter><initializer>0</initializer></methodparam> </methodsynopsis> <para> Sends a CTRL event to another process in the same process group. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <variablelist> <varlistentry> <term><parameter>event</parameter></term> <listitem> <para> The <literal>CTRL</literal> even to send; either <constant>PHP_WINDOWS_EVENT_CTRL_C</constant> or <constant>PHP_WINDOWS_EVENT_CTRL_BREAK</constant>. </para> </listitem> </varlistentry> <varlistentry> <term><parameter>pid</parameter></term> <listitem> <para> The ID of the process to which to send the event to. If <literal>0</literal> is given, the event is sent to all processes of the process group. </para> </listitem> </varlistentry> </variablelist> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <example xml:id="sapi-windows-generate-ctrl-event.example.basic"> <title>Basic <function>sapi_windows_generate_ctrl_event</function> Usage</title> <para> This example shows how to pass along <literal>CTRL+BREAK</literal> events to a child process. In this case the child process echoes <literal>I'm still alive</literal> every second, until the user presses <literal>CTRL+BREAK</literal>, what causes only the child process to be terminated. </para> <programlisting role="php"> <![CDATA[ <?php // forward CTRL+BREAK events to the child process sapi_windows_set_ctrl_handler('sapi_windows_generate_ctrl_event'); // create a child process which echoes every second $cmd = ['php', '-r', 'while (true) { echo "I\'m still alive\n"; sleep(1); }']; $descspec = array(['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']); $options = ['create_process_group' => true]; $proc = proc_open($cmd, $descspec, $pipes, null, null, $options); while (true) { echo fgets($pipes[1]); } ?> ]]> </programlisting> </example> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <simplelist> <member><function>proc_open</function></member> <member><function>sapi_windows_set_ctrl_handler</function></member> </simplelist> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"~/.phpdoc/manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->