Bug #60120 [Com]: proc_open hangs with stdin/out with 2048+ bytes

2013-03-15 Thread hanskrentel at yahoo dot de
Edit report at https://bugs.php.net/bug.php?id=60120edit=1

 ID: 60120
 Comment by: hanskrentel at yahoo dot de
 Reported by:paj...@php.net
 Summary:proc_open hangs with stdin/out with 2048+ bytes
 Status: Closed
 Type:   Bug
 Package:Filesystem function related
 Operating System:   windows
 PHP Version:Irrelevant
 Assigned To:pajoye
 Block user comment: N
 Private report: N

 New Comment:

In case you don't want to re-open this issue as not fixed, I made a more 
specific 
report with 4097+ bytes pipes that cause a hang here:

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


Previous Comments:

[2012-07-24 23:39:19] ras...@php.net

Automatic comment on behalf of pajoye
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=8bd6b9d87af4ec3953bd760c65aea506c70b840b
Log: - fixed bug #60120, proc_open's streams may hang with stdin/out/err when 
the data exceeds or is equal to 2048 bytes


[2012-04-18 09:48:13] larue...@php.net

Automatic comment on behalf of pajoye
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=8bd6b9d87af4ec3953bd760c65aea506c70b840b
Log: - fixed bug #60120, proc_open's streams may hang with stdin/out/err when 
the data exceeds or is equal to 2048 bytes


[2012-02-19 14:48:40] nicolas dot sauveur at gmail dot com

seems similar to https://bugs.php.net/bug.php?id=51800


[2012-02-19 14:34:42] nicolas dot sauveur at gmail dot com

On my install of php 5.3.9 (windows 7 wamp server 2, apache 2.2.21), the bug 
has 
only been fixed for 2048 to 4096 bytes. Above that, proc_open still hangs for 
me.

I use the same test as above, with
$stdin = str_repeat('*', 4097 );


[2011-10-26 08:41:57] paj...@php.net

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

yes (see the commit tab :), I forgot to close it. Thanks for the headup!




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


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


Bug #60120 [Com]: proc_open hangs with stdin/out with 2048+ bytes

2012-02-19 Thread nicolas dot sauveur at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=60120edit=1

 ID: 60120
 Comment by: nicolas dot sauveur at gmail dot com
 Reported by:paj...@php.net
 Summary:proc_open hangs with stdin/out with 2048+ bytes
 Status: Closed
 Type:   Bug
 Package:Filesystem function related
 Operating System:   windows
 PHP Version:Irrelevant
 Assigned To:pajoye
 Block user comment: N
 Private report: N

 New Comment:

On my install of php 5.3.9 (windows 7 wamp server 2, apache 2.2.21), the bug 
has 
only been fixed for 2048 to 4096 bytes. Above that, proc_open still hangs for 
me.

I use the same test as above, with
$stdin = str_repeat('*', 4097 );


Previous Comments:

[2011-10-26 08:41:57] paj...@php.net

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

yes (see the commit tab :), I forgot to close it. Thanks for the headup!


[2011-10-26 06:23:54] fabien at symfony dot com

AFAIK, this bug has been fixed here: http://svn.php.net/viewvc?
view=revisionrevision=318366


[2011-10-24 12:39:53] paj...@php.net

Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=318366
Log: - fixed bug #60120, proc_open's streams may hang with stdin/out/err when 
the data exceeds or is equal to 2048 bytes


[2011-10-24 12:10:03] paj...@php.net

Description:

The stream used to read data from stdin/out/err hangs if the data passed is 
getting larger than 2048, under certain circumstances. 

Test script:
---
error_reporting(E_ALL);

$cmd = 'php -r fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); 
fwrite(STDERR, $in);';
$descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 
'w'));
$stdin = str_repeat('*', 1024 * 16) . '!';
$stdin = str_repeat('*', 2049 );

$options = array_merge(array('suppress_errors' = true, 'binary_pipes' = true, 
'bypass_shell' = false));
$process = proc_open($cmd, $descriptors, $pipes, getcwd(), array(), $options);

foreach ($pipes as $pipe) {
stream_set_blocking($pipe, false);
}
$writePipes = array($pipes[0]);
$stdinLen = strlen($stdin);
$stdinOffset = 0;

unset($pipes[0]);

while ($pipes || $writePipes) {
$r = $pipes;
$w = $writePipes;
$e = null;
$n = stream_select($r, $w, $e, 60);

if (false === $n) {
break;
} elseif ($n === 0) {
proc_terminate($process);

}
if ($w) {
$written = fwrite($writePipes[0], (binary)substr($stdin, $stdinOffset), 
8192);
if (false !== $written) {
$stdinOffset += $written;
}
if ($stdinOffset = $stdinLen) {
fclose($writePipes[0]);
$writePipes = null;
}
}

foreach ($r as $pipe) {
$type = array_search($pipe, $pipes);
$data = fread($pipe, 8192);
if (false === $data || feof($pipe)) {
fclose($pipe);
unset($pipes[$type]);
}
}
}







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


Bug #60120 [Com]: proc_open hangs with stdin/out with 2048+ bytes

2012-02-19 Thread nicolas dot sauveur at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=60120edit=1

 ID: 60120
 Comment by: nicolas dot sauveur at gmail dot com
 Reported by:paj...@php.net
 Summary:proc_open hangs with stdin/out with 2048+ bytes
 Status: Closed
 Type:   Bug
 Package:Filesystem function related
 Operating System:   windows
 PHP Version:Irrelevant
 Assigned To:pajoye
 Block user comment: N
 Private report: N

 New Comment:

seems similar to https://bugs.php.net/bug.php?id=51800


Previous Comments:

[2012-02-19 14:34:42] nicolas dot sauveur at gmail dot com

On my install of php 5.3.9 (windows 7 wamp server 2, apache 2.2.21), the bug 
has 
only been fixed for 2048 to 4096 bytes. Above that, proc_open still hangs for 
me.

I use the same test as above, with
$stdin = str_repeat('*', 4097 );


[2011-10-26 08:41:57] paj...@php.net

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

yes (see the commit tab :), I forgot to close it. Thanks for the headup!


[2011-10-26 06:23:54] fabien at symfony dot com

AFAIK, this bug has been fixed here: http://svn.php.net/viewvc?
view=revisionrevision=318366


[2011-10-24 12:39:53] paj...@php.net

Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=318366
Log: - fixed bug #60120, proc_open's streams may hang with stdin/out/err when 
the data exceeds or is equal to 2048 bytes


[2011-10-24 12:10:03] paj...@php.net

Description:

The stream used to read data from stdin/out/err hangs if the data passed is 
getting larger than 2048, under certain circumstances. 

Test script:
---
error_reporting(E_ALL);

$cmd = 'php -r fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); 
fwrite(STDERR, $in);';
$descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 
'w'));
$stdin = str_repeat('*', 1024 * 16) . '!';
$stdin = str_repeat('*', 2049 );

$options = array_merge(array('suppress_errors' = true, 'binary_pipes' = true, 
'bypass_shell' = false));
$process = proc_open($cmd, $descriptors, $pipes, getcwd(), array(), $options);

foreach ($pipes as $pipe) {
stream_set_blocking($pipe, false);
}
$writePipes = array($pipes[0]);
$stdinLen = strlen($stdin);
$stdinOffset = 0;

unset($pipes[0]);

while ($pipes || $writePipes) {
$r = $pipes;
$w = $writePipes;
$e = null;
$n = stream_select($r, $w, $e, 60);

if (false === $n) {
break;
} elseif ($n === 0) {
proc_terminate($process);

}
if ($w) {
$written = fwrite($writePipes[0], (binary)substr($stdin, $stdinOffset), 
8192);
if (false !== $written) {
$stdinOffset += $written;
}
if ($stdinOffset = $stdinLen) {
fclose($writePipes[0]);
$writePipes = null;
}
}

foreach ($r as $pipe) {
$type = array_search($pipe, $pipes);
$data = fread($pipe, 8192);
if (false === $data || feof($pipe)) {
fclose($pipe);
unset($pipes[$type]);
}
}
}







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


Bug #60120 [Com]: proc_open hangs with stdin/out with 2048+ bytes

2011-10-26 Thread fabien at symfony dot com
Edit report at https://bugs.php.net/bug.php?id=60120edit=1

 ID: 60120
 Comment by: fabien at symfony dot com
 Reported by:paj...@php.net
 Summary:proc_open hangs with stdin/out with 2048+ bytes
 Status: Assigned
 Type:   Bug
 Package:Filesystem function related
 Operating System:   windows
 PHP Version:Irrelevant
 Assigned To:pajoye
 Block user comment: N
 Private report: N

 New Comment:

AFAIK, this bug has been fixed here: http://svn.php.net/viewvc?
view=revisionrevision=318366


Previous Comments:

[2011-10-24 12:39:53] paj...@php.net

Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revisionamp;revision=318366
Log: - fixed bug #60120, proc_open's streams may hang with stdin/out/err when 
the data exceeds or is equal to 2048 bytes


[2011-10-24 12:10:03] paj...@php.net

Description:

The stream used to read data from stdin/out/err hangs if the data passed is 
getting larger than 2048, under certain circumstances. 

Test script:
---
error_reporting(E_ALL);

$cmd = 'php -r fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); 
fwrite(STDERR, $in);';
$descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 
'w'));
$stdin = str_repeat('*', 1024 * 16) . '!';
$stdin = str_repeat('*', 2049 );

$options = array_merge(array('suppress_errors' = true, 'binary_pipes' = true, 
'bypass_shell' = false));
$process = proc_open($cmd, $descriptors, $pipes, getcwd(), array(), $options);

foreach ($pipes as $pipe) {
stream_set_blocking($pipe, false);
}
$writePipes = array($pipes[0]);
$stdinLen = strlen($stdin);
$stdinOffset = 0;

unset($pipes[0]);

while ($pipes || $writePipes) {
$r = $pipes;
$w = $writePipes;
$e = null;
$n = stream_select($r, $w, $e, 60);

if (false === $n) {
break;
} elseif ($n === 0) {
proc_terminate($process);

}
if ($w) {
$written = fwrite($writePipes[0], (binary)substr($stdin, $stdinOffset), 
8192);
if (false !== $written) {
$stdinOffset += $written;
}
if ($stdinOffset = $stdinLen) {
fclose($writePipes[0]);
$writePipes = null;
}
}

foreach ($r as $pipe) {
$type = array_search($pipe, $pipes);
$data = fread($pipe, 8192);
if (false === $data || feof($pipe)) {
fclose($pipe);
unset($pipes[$type]);
}
}
}







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