Proper shell execution in PHP

前端 未结 4 757
情歌与酒
情歌与酒 2021-02-14 16:53

The problem

I was using a function that made use of proc_open() to invoke shell commands. It seems the way I was doing STDIO was wrong and sometimes cause

4条回答
  •  天命终不由人
    2021-02-14 17:53

    You've missed this note in the PHP manual for stream_select():

    When stream_select() returns, the arrays read, write and except are modified to indicate which stream resource(s) actually changed status.

    You need to re-create the arrays before calling stream_select() each time.

    Depending on the process you're opening, this may be why your example still blocks.

提交回复
热议问题