sapi_windows_generate_ctrl_event Send a CTRL event to another process
发表日期:2021-07-01 10:15:43 | 来源: | | 浏览(1082) 分类:杂项 函数
sapi_windows_generate_ctrl_event
(PHP 7 >= 7.4.0, PHP 8)
sapi_windows_generate_ctrl_event — Send a CTRL event to another process
说明
$event
, int $pid
= 0): boolSends a CTRL event to another process in the same process group.
参数
-
event
-
The
CTRL
even to send; eitherPHP_WINDOWS_EVENT_CTRL_C
orPHP_WINDOWS_EVENT_CTRL_BREAK
. -
pid
-
The ID of the process to which to send the event to. If
0
is given, the event is sent to all processes of the process group.
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 Basic sapi_windows_generate_ctrl_event() Usage
This example shows how to pass along CTRL+BREAK
events to a child
process. In this case the child process echoes I'm still alive
every second, until the user presses CTRL+BREAK
, what causes
only the child process to be terminated.
<?php // forward CTRL+BREAK events to the child processsapi_windows_set_ctrl_handler('sapi_windows_generate_ctrl_event'); // create a child process which echoes every second$cmd = ['php', '-r', 'while (true) { echo "I\'m still alive\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]); } ?>
参见
- proc_open() - 执行一个命令,并且打开用来输入/输出的文件指针。
- sapi_windows_set_ctrl_handler() - Set or remove a CTRL event handler
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- connection_aborted 检查客户端是否已经断开(0)
- connection_status 返回连接的状态位(0)
- constant 返回一个常量的值(0)
- define 定义一个常量(0)
- defined 检查某个名称的常量是否存在(0)
- die 等同于 exit()(0)
- eval 把字符串作为PHP代码执行(0)
- exit 输出一个消息并且退出当前脚本(0)
- get_browser 获取浏览器具有的功能(0)
- __halt_compiler 中断编译器的执行(0)
- highlight_file 语法高亮一个文件(0)
- highlight_string 字符串的语法高亮(0)
- hrtime 获取系统的高精度时间(0)
- ignore_user_abort 设置客户端断开连接时是否中断脚本的执行(0)
- pack 将数据打包成二进制字符串(0)
- php_strip_whitespace 返回删除注释和空格后的PHP源码(0)
- sapi_windows_cp_conv Convert string from one codepage to another(0)
- sapi_windows_cp_get Get current codepage(0)
- sapi_windows_cp_is_utf8 Indicates whether the codepage is UTF-8 compatible(0)
- sapi_windows_cp_set Set process codepage(0)
- sapi_windows_generate_ctrl_event Send a CTRL event to another process(0)
- sapi_windows_set_ctrl_handler Set or remove a CTRL event handler(0)
- sapi_windows_vt100_support Get or set VT100 support for the specified stream associated to an output buffer of a Windows console.(0)
- show_source 别名 highlight_file()(0)
- sleep 延缓执行(0)
- sys_getloadavg 获取系统的负载(load average)(0)
- time_nanosleep 延缓执行若干秒和纳秒(0)
- time_sleep_until 使脚本睡眠到指定的时间为止。(0)
- uniqid 生成一个唯一ID(0)
- unpack Unpack data from binary string(0)
- usleep 以指定的微秒数延迟执行(0)
- 字符串 函数(101)