mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-20 10:58:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@348652 c90b9560-bf6c-de11-be94-00142212c4b1
132 lines
3.9 KiB
XML
132 lines
3.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<refentry xml:id="function.sapi-windows-set-ctrl-handler" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>sapi_windows_set_ctrl_handler</refname>
|
|
<refpurpose>Set or remove a CTRL event handler</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>sapi_windows_set_ctrl_handler</methodname>
|
|
<methodparam><type>callable</type><parameter>callable</parameter></methodparam>
|
|
<methodparam choice="opt"><type>bool</type><parameter>add</parameter><initializer>&true;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Sets or removes a <literal>CTRL</literal> event handler, which allows Windows
|
|
CLI processes to intercept or ignore <literal>CTRL+C</literal> and
|
|
<literal>CTRL+BREAK</literal> events. Note that in multithreaded environments,
|
|
this is only possible when called from the main thread.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>callable</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
A callback function to set or remove. If set, this function will be called
|
|
whenever a <literal>CTRL+C</literal> or <literal>CTRL+BREAK</literal> event
|
|
occurs. The function is supposed to have the following signature:
|
|
<methodsynopsis>
|
|
<type>void</type><methodname>handler</methodname>
|
|
<methodparam><type>int</type><parameter>event</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>event</parameter></term>
|
|
<listitem>
|
|
<simpara>
|
|
The <literal>CTRL</literal> event which has been received;
|
|
either <constant>PHP_WINDOWS_EVENT_CTRL_C</constant>
|
|
or <constant>PHP_WINDOWS_EVENT_CTRL_BREAK</constant>.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
Setting a &null; <parameter>callable</parameter> causes the process to ignore
|
|
<literal>CTRL+C</literal> events, but not <literal>CTRL+BREAK</literal> events.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>add</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
If &true;, the handler is set. If &false;, the handler is removed.
|
|
</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-set-ctrl-handler.example.basic">
|
|
<title>Basic <function>sapi_windows_set_ctrl_handler</function> Usage</title>
|
|
<para>
|
|
This example shows how to intercept <literal>CTRL</literal> events.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
function ctrl_handler(int $event)
|
|
{
|
|
switch ($event) {
|
|
case PHP_WINDOWS_EVENT_CTRL_C:
|
|
echo "You have pressed CTRL+C\n";
|
|
break;
|
|
case PHP_WINDOWS_EVENT_CTRL_BREAK:
|
|
echo "You have pressed CTRL+BREAK\n";
|
|
break;
|
|
}
|
|
}
|
|
|
|
sapi_windows_set_ctrl_handler('ctrl_handler');
|
|
while (true); // infinite loop, so the handler can be triggered
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><function>sapi_windows_generate_ctrl_event</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
|
|
-->
|