File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 12
12
<programlisting role =" php" >
13
13
<![CDATA[
14
14
<?php
15
- declare(ticks=1 );
15
+ pcntl_async_signals(true );
16
16
17
17
$pid = pcntl_fork();
18
18
if ($pid == -1) {
Original file line number Diff line number Diff line change 135
135
<programlisting role =" php" >
136
136
<![CDATA[
137
137
<?php
138
- // tick use required
139
- declare(ticks = 1);
138
+ pcntl_async_signals(true);
140
139
141
140
// signal handler function
142
141
function sig_handler($signo)
@@ -189,13 +188,31 @@ echo "Done\n";
189
188
<para >
190
189
<function >pcntl_signal</function > doesn't stack the signal handlers, but replaces them.
191
190
</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 >
192
206
</refsect1 ><!-- }}} -->
193
207
194
208
<refsect1 role =" seealso" >
195
209
&reftitle.seealso;
196
210
<para >
197
211
<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 >
198
214
<member ><function >pcntl_fork</function ></member >
215
+ <member ><function >pcntl_signal_dispatch</function ></member >
199
216
<member ><function >pcntl_waitpid</function ></member >
200
217
</simplelist >
201
218
</para >
You can’t perform that action at this time.
0 commit comments