-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathsapi-windows-generate-ctrl-event.xml
115 lines (108 loc) · 3.84 KB
/
sapi-windows-generate-ctrl-event.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 658c808b558cab3ab64cc86f55cc9056aa7818e6 Maintainer: rjhdby Status: ready -->
<!-- Reviewed: no -->
<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>Послать событие CTRL другому процессу</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>
Послать событие CTRL другому процессу в той же группе процессов.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>event</parameter></term>
<listitem>
<para>
Событие <literal>CTRL</literal>;
<constant>PHP_WINDOWS_EVENT_CTRL_C</constant>
или <constant>PHP_WINDOWS_EVENT_CTRL_BREAK</constant>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>pid</parameter></term>
<listitem>
<para>
Идентификатор процесса, которому необходимо послать событие.
Если задано как <literal>0</literal>, то событие будет послано всем
процессам в группе.
</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>Использование <function>sapi_windows_generate_ctrl_event</function></title>
<para>
В этом примере показано, как послать события
<literal>CTRL+BREAK</literal> дочернему процессу.
В данном случае дочерний процесс будет печатать
<literal>Я всё ещё жив!</literal> раз в секунду, пока пользователь
не нажмёт <literal>CTRL+BREAK</literal>. После этого дочерний
процесс завершится.
</para>
<programlisting role="php">
<![CDATA[
<?php
// Пересылка событий CTRL+BREAK дочернему процессу
sapi_windows_set_ctrl_handler('sapi_windows_generate_ctrl_event');
// Создаём дочерний процесс
$cmd = ['php', '-r', 'while (true) { echo "Я всё ещё жив!\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
-->