Reputation: 1874
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 with 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
}
Upvotes: 4
Views: 475
Reputation: 360782
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)
Upvotes: 1