Unfortunately, I've found all the solutions for executing external programs not suitable, so I use my own implementation, which is pcntl_exec
after pcntl_fork
.
But now I need to redirect stderr/stdout of the executed program into some file. It's obvious, that I should use some sort of dup2
Linux call after pcntl_fork
, but the only dup2
I can see in PHP is eio_dup2
, which looks like it operates not the regular streams (like stderr/stdout), but some async streams.
How can I call dup2
from PHP or how can I redirect std* without it?
The same question (though, without details) has no answers: How do I invoke a dup2() syscall from PHP ?