note 107856 added to function.proc-open
| From: | devel at romanr dot info | Date: | Sat, 10 Mar 2012 08:04:04 +0000 |
| Subject: | note 107856 added to function.proc-open | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186573@lists.php.net to get a copy of this message | ||
The call works as should. No bugs.
But. In most cases you won't able to work with pipes in blocking mode.
When your output pipe (process' input one, $pipes[0]) is blocking, there is a case, when you
and the process are blocked on output.
When your input pipe (process' output one, $pipes[1]) is blocking, there is a case, when you
and the process both are blocked on own input.
So you should switch pipes into NONBLOCKING mode (stream_set_blocking).
Then, there is a case, when you're not able to read anything (fread($pipes[1],...) ==
"") either write (fwrite($pipes[0],...) == 0). In this case, you better check the process
is alive (proc_get_status) and if it still is - wait for some time (stream_select). The situation is
truly asynchronous, the process may be busy working, processing your data.
Using shell effectively makes not possible to know whether the command is exists - proc_open always
returns valid resource. You may even write some data into it (into shell, actually). But eventually
it will terminate, so check the process status regularly.
I would advice not using mkfifo-pipes, because filesystem fifo-pipe (mkfifo) blocks open/fopen call
(!!!) until somebody opens other side (unix-related behavior). In case the pipe is opened not by
shell and the command is crashed or is not exists you will be blocked forever.
----
Server IP: 195.54.192.44
Probable Submitter: 188.124.232.155
----
Manual Page -- http://www.php.net/manual/en/function.proc-open.php
Edit -- https://master.php.net/note/edit/107856
Del: integrated -- https://master.php.net/note/delete/107856/integrated
Del: useless -- https://master.php.net/note/delete/107856/useless
Del: bad code -- https://master.php.net/note/delete/107856/bad+code
Del: spam -- https://master.php.net/note/delete/107856/spam
Del: non-english -- https://master.php.net/note/delete/107856/non-english
Del: in docs -- https://master.php.net/note/delete/107856/in+docs
Del: other reasons-- https://master.php.net/note/delete/107856
Reject -- https://master.php.net/note/reject/107856
Search -- https://master.php.net/manage/user-notes.php