sapi_windows_set_ctrl_handler
Set or remove a CTRL event handler
&reftitle.description;
boolsapi_windows_set_ctrl_handler
callablecallable
booladd&true;
Sets or removes a CTRL event handler, which allows Windows
CLI processes to intercept or ignore CTRL+C and
CTRL+BREAK events. Note that in multithreaded environments,
this is only possible when called from the main thread.
&reftitle.parameters;
callable
A callback function to set or remove. If set, this function will be called
whenever a CTRL+C or CTRL+BREAK event
occurs. The function is supposed to have the following signature:
voidhandler
intevent
event
The CTRL event which has been received;
either PHP_WINDOWS_EVENT_CTRL_C
or PHP_WINDOWS_EVENT_CTRL_BREAK.
Setting a &null; callable causes the process to ignore
CTRL+C events, but not CTRL+BREAK events.
add
If &true;, the handler is set. If &false;, the handler is removed.
&reftitle.returnvalues;
&return.success;
&reftitle.examples;
Basic sapi_windows_set_ctrl_handler Usage
This example shows how to intercept CTRL events.
]]>
&reftitle.seealso;
sapi_windows_generate_ctrl_event