[prev in list] [next in list] [prev in thread] [next in thread] 

List:       phpdoc
Subject:    Re: empty $descriptorspec for proc_open() needs documentation
From:       Karoly Negyesi <karoly () negyesi ! net>
Date:       2021-03-28 18:54:34
Message-ID: CAOfzkkwqJsOt5SmEZptoHbSo6Ns2hQoEyJ_42mXd=A4JmPpMAQ () mail ! gmail ! com
[Download RAW message or body]

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
>
>
>
>

[Attachment #3 (text/html)]

<div dir="ltr">Thanks a lot. I dug more into the C source and my memories of C and \
posted  <a href="https://stackoverflow.com/a/66844926/308851">https://stackoverflow.com/a/66844926/308851</a> \
<div><br></div><div>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.</div><div><br></div><div>Thanks again for all the \
help</div><div><br></div><div>Karoly \
Negyesi</div><div><br></div><div><br><div><br></div><div><br></div></div></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 28, 2021 at 4:38 AM \
John Stevenson &lt;<a \
href="mailto:john-stevenson@blueyonder.co.uk">john-stevenson@blueyonder.co.uk</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

    
<div><p>Hi Karoly,</p><p>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.<br></p><p>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&#39;t always work, but this turns out \
to have been due to old pipe handling issues (now much improved).<br></p><p>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. \
<br></p><p>Cheers,<br></p><p>John Stevenson<br></p><blockquote type="cite">On 28 \
March 2021 at 03:59 Karoly Negyesi &lt;<a href="mailto:karoly@negyesi.net" \
target="_blank">karoly@negyesi.net</a>&gt; wrote: <br> <br><div \
dir="ltr">Hello,<div><br></div><div>composer/xdebug-handler in <a \
href="https://github.com/composer/xdebug-handler/blob/main/src/XdebugHandler.php#L276" \
target="_blank">https://github.com/composer/xdebug-handler/blob/main/src/XdebugHandler.php#L276</a> \
uses an empty $descriptorspec for proc_open():</div><div><br></div><div>$process = \
proc_open($cmd, array(), $pipes); <br></div><div><br></div><div>The documentation \
does not cover this case.   I even tried to peek at the source code and still \
can&#39;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&#39;d the \
esteemed maintainers who wrote this excellent code in hoping for  some \
insight.</div><div><br></div><div>Thanks,</div><div><br></div><div>Karoly \
Negyesi</div><div><br></div><div>  <br></div></div></blockquote></div>  \
</blockquote></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic