大网数据广告活动
PHP 语言与运行手册

EvChild::__construct · Constructs the EvChild watcher object

· 52CE 我爱测

EvChild::__construct — Constructs the EvChild watcher object

EvChild::__construct

(PECL ev >= 0.2.0)

EvChild::__construct — Constructs the EvChild watcher object

Description

public function EvChild::__construct(
     int $pid ,
     bool $trace ,
     callable $callback ,
     mixed $data = null ,
     int $priority = 0
)

Constructs the EvChild watcher object.

Call the callback when a status change for process ID pid (or any PID if pid is 0) has been received(a status change happens when the process terminates or is killed, or, when trace is true, additionally when it is stopped or continued). In other words, when the process receives a SIGCHLD, Ev will fetch the outstanding exit/wait status for all changed/zombie children and call the callback.

It is valid to install a child watcher after an EvChild has exited but before the event loop has started its next iteration. For example, first one calls fork, then the new child process might exit, and only then an EvChild watcher is installed in the parent for the new PID.

You can access both exit/tracing status and pid by using the rstatus and rpid properties of the watcher object.

The number of PID watchers per PID is unlimited. All of them will be called.

The EvChild::createStopped() method doesn't start(activate) the newly created watcher.

Parameters

pid

Wait for status changes of process PID(or any process if PID is specified as 0 ).

trace

If false, only activate the watcher when the process terminates. Otherwise(true) additionally activate the watcher when the process is stopped or continued.

callback

See Watcher callbacks.

data

Custom data associated with the watcher.

priority

Watcher priority

See Also

  • EvLoop::child() - Creates EvChild object associated with the current event loop

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。