Bug #47918 [Com]: stream_set_blocking() does not work with pipes opened with proc_open()

From: Date: Fri, 06 Jun 2014 20:26:06 +0000
Subject: Bug #47918 [Com]: stream_set_blocking() does not work with pipes opened with proc_open()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186087@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=47918&edit=1

 ID:                 47918
 Comment by:         cxjohnson at gmail dot com
 Reported by:        RQuadling at GMail dot com
 Summary:            stream_set_blocking() does not work with pipes
                     opened with proc_open()
 Status:             Open
 Type:               Bug
 Package:            Streams related
 Operating System:   Windows
 PHP Version:        5.*, 6CVS (2009-06-19
 Block user comment: N
 Private report:     N

 New Comment:

Or more precisely, stream_get_meta_data() is broken.  It reports the mode as blocked, yet a read on
the pipe while after stream_set_blocking($pipe, 0) does NOT block, as would be expected.


Previous Comments:
------------------------------------------------------------------------
[2014-06-06 20:15:53] cxjohnson at gmail dot com

Still broken in 5.4+.

This fails in the same way on Mac OSX 10.9.3 with PHP 5.4.24, and on FreeBSD 9.2-RELEASE with PHP
5.4.25.

------------------------------------------------------------------------
[2012-09-21 14:40:56] schmod at gmail dot com

Is this really true?

I can run a number of console applications via proc_open() without encountering 
blocking on win32.  

However, I have encountered a number of applications that will cause PHP hang on 
fread() until the process closes (regardless of whether or not the buffer has filled).

This needs to either be categorized as a bug, or the documentation needs to be updated 
to explain this unexpected behavior on win32.  

PHP 5.4.3/Win7x64.

------------------------------------------------------------------------
[2009-08-24 08:59:40] RQuadling at GMail dot com

Essentially, non-blocking streams don't exist in win32 PHP.

They work fine for non-win32, so maybe this should become a feature 
request.

From reading the MSDN sites regarding non-blocking/blocking, it seems 
that a completely different mechanism for file handling needs to be 
used.

Other scripting languages have solved this issue in a different fashion, 
using an additional thread to process the stream.

------------------------------------------------------------------------
[2009-08-22 05:51:48] nobodyy at mailinator dot com

Same problem here...

If we use proc_open and the output (pipes[1]) is greater than 2kb, 
the application just gets stuck!

I don't have any idea why, but it is never terminated, unless we do 
an FREAD of FGETS at the pipe[1].

But we can't do the FGETS if we don't know if there is content to be 
read. There is when stream_set_blocking should save the day.. But it 
doesn't work! :(

------------------------------------------------------------------------
[2009-07-28 09:47:05] morrisdavidd at gmail dot com

I tested this on PHP 5.3 (on Linux) and duplicated the error that the print_r command shows blocking
as true. HOWEVER, the stream does not block when actually tested... a simple test script can be
created by adding a line and slightly modifying the scripts found at:

http://bugs.php.net/bug.php?id=49084

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=47918


--
Edit this bug report at https://bugs.php.net/bug.php?id=47918&edit=1


Thread (14 messages)

« previous php.bugs (#186087) next »