note 103189 added to function.proc-get-status
| From: | LachlanMulcahy at osu1 dot php dot net | Date: | Wed, 30 Mar 2011 19:40:03 +0000 |
| Subject: | note 103189 added to function.proc-get-status | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178359@lists.php.net to get a copy of this message | ||
It is worth noting that proc_get_status will continue to indicate the process that you spawned is
running (because it is!) until that process has been able to write everything it wants to write to
the STDOUT and STDERR streams.
PHP seems to use a buffer for this and so the spawned process can can get it's write calls to
return immediately.
However, once this buffer is full the write call will block until you read out some of the
information from the stream/pipe.
This can manifest itself in many ways but generally the called process will still be running, but
just not doing anything as it is blocking on being able to write more to STDERR or STDOUT --
whichever stream buffer is full.
To work around this you should include in your loop of checking proc_get_status' running
element a "stream_get_contents" on the relevant pipes.
I generally use stream_set_blocking($pipies[2], 0) kind of calls to make sure that the
stream_get_contents call will not block if there is no data in the stream.
This one had me stumped for a while, so hopefully it helps someone!
----
Server IP: 64.71.164.2
Probable Submitter: 209.213.206.2
----
Manual Page -- http://www.php.net/manual/en/function.proc-get-status.php
Edit -- https://master.php.net/note/edit/103189
Del: integrated -- https://master.php.net/note/delete/103189/integrated
Del: useless -- https://master.php.net/note/delete/103189/useless
Del: bad code -- https://master.php.net/note/delete/103189/bad+code
Del: spam -- https://master.php.net/note/delete/103189/spam
Del: non-english -- https://master.php.net/note/delete/103189/non-english
Del: in docs -- https://master.php.net/note/delete/103189/in+docs
Del: other reasons-- https://master.php.net/note/delete/103189
Reject -- https://master.php.net/note/reject/103189
Search -- https://master.php.net/manage/user-notes.php