Skip to content

Commit e91b2dd

Browse files
authored
pcntl_signal: Switch to pcntl_async_signals and improve documentation (#4539)
1 parent bfc89e6 commit e91b2dd

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

reference/pcntl/examples.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<programlisting role="php">
1313
<![CDATA[
1414
<?php
15-
declare(ticks=1);
15+
pcntl_async_signals(true);
1616
1717
$pid = pcntl_fork();
1818
if ($pid == -1) {

reference/pcntl/functions/pcntl-signal.xml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@
135135
<programlisting role="php">
136136
<![CDATA[
137137
<?php
138-
// tick use required
139-
declare(ticks = 1);
138+
pcntl_async_signals(true);
140139
141140
// signal handler function
142141
function sig_handler($signo)
@@ -189,13 +188,31 @@ echo "Done\n";
189188
<para>
190189
<function>pcntl_signal</function> doesn't stack the signal handlers, but replaces them.
191190
</para>
191+
<refsect2>
192+
<title>Dispatch Methods</title>
193+
<para>
194+
There are several methods of dispatching signal handlers:
195+
<simplelist>
196+
<member>Asynchronous dispatch with <function>pcntl_async_signals</function> enabled. This is the recommended method</member>
197+
<member>Setting <link linkend="control-structures.declare.ticks">tick</link> frequency</member>
198+
<member>Manual dispatch with <function>pcntl_signal_dispatch</function></member>
199+
</simplelist>
200+
</para>
201+
<para>
202+
When signals are dispatched asynchronously or using tick-based execution, blocking functions like
203+
<function>sleep</function> may be interrupted.
204+
</para>
205+
</refsect2>
192206
</refsect1><!-- }}} -->
193207

194208
<refsect1 role="seealso">
195209
&reftitle.seealso;
196210
<para>
197211
<simplelist>
212+
<member><link xlink:href="https://en.wikipedia.org/wiki/Signal_(IPC)">Signal (IPC)</link> on Wikipedia</member>
213+
<member><function>pcntl_async_signals</function></member>
198214
<member><function>pcntl_fork</function></member>
215+
<member><function>pcntl_signal_dispatch</function></member>
199216
<member><function>pcntl_waitpid</function></member>
200217
</simplelist>
201218
</para>

0 commit comments

Comments
 (0)