Re: empty $descriptorspec for proc_open() needs documentation
Karoly Negyesi <[email protected]>
| Newsgroups | gmane.comp.php.documentation.general |
|---|---|
| Message-ID | <CAOfzkkwqJsOt5SmEZptoHbSo6Ns2hQoEyJ_42mXd=A4JmPpMAQ@mail.gmail.com> |
Thanks a lot. I dug more into the C source and my memories of C and posted https://stackoverflow.com/a/66844926/308851 Now. This example IMO should be in the manual -- do we have any examples in there using named PHP files? I could use an example I could copy :) I also asked in IRC. Thanks again for all the help Karoly Negyesi On Sun, Mar 28, 2021 at 4:38 AM John Stevenson < [email protected]> wrote: > Hi Karoly, > > For your information proc-open is different from the other execution > functions in that it uses the existing stdin/our/err file descriptors (or > WinAPI StdHandles) unless overridden by values in $descriptorspec. In > contrast exec, paththru, shell_exec, system etc open a pipe to the process. > > Because it was not obvious in the documentation that $descriptorspec could > be empty (to me, anyway), we originally used passthru to restart our > process. Also, my experience with proc_open on Windows had been that things > didn't always work, but this turns out to have been due to old pipe > handling issues (now much improved). > > Using proc_open in this way results in a passthru function without the > pipe, which means that an is_atty function on STDOUT no longer returns > false. It would be great to see the proc_open documentation updated with > this example. > > Cheers, > > John Stevenson > > On 28 March 2021 at 03:59 Karoly Negyesi <[email protected]> wrote: > > Hello, > > composer/xdebug-handler in > https://github.com/composer/xdebug-handler/blob/main/src/XdebugHandler.php#L276 > uses an empty $descriptorspec for proc_open(): > > $process = proc_open($cmd, array(), $pipes); > > The documentation does not cover this case. I even tried to peek at the > source code and still can't say I get it but then again the last time I did > C seriously was literally in the last century :) As attested by > drush-launcher which uses xdebug-handler to launch a customized psysh > without xdebug, it most certainly does work, the child process accepts > input from the terminal and outputs to the terminal nicely. I am quite > ready to document this in the PHP manual once I understand it. I CC'd the > esteemed maintainers who wrote this excellent code in hoping for some > insight. > > Thanks, > > Karoly Negyesi > > > >