Re: empty $descriptorspec for proc_open() needs documentation

From: Date: Sun, 28 Mar 2021 18:54:34 +0000
Subject: Re: empty $descriptorspec for proc_open() needs documentation
References: 1 2  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969387865@lists.php.net to get a copy of this message
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 <
john-stevenson@blueyonder.co.uk> 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 <karoly@negyesi.net> 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
>
>
>
>


Thread (2 messages)

« previous php.doc (#969387865) next »