开发者

How do I have a child process write back to the STDIN of its parent in PHP?

In PHP, is there a way to have a child process forked off with pcntl_fork() write data directly back to its parent's stdin? I don't mean w开发者_开发知识库ith a separate pipe--the stdin resource itself? (It has to be stdin because, in short, what the parent is doing won't work right unless it can bind its own stdin to incoming data directly--a separate pipe won't work.) As in:

$pid = pcntl_fork();
if (!$pid) {
  // do fun child process stuff
  // write data back to parent's STDIN
}


On Linux (don't know how prevalent this would be for Unix in general), a process' stdin can be gotten at via /proc/$PID/fd/0 (as well as stdout/stderr at 1 & 2 rather than 0)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜