Fwd: [PHP] proc_open and buffer limit?
| From: | Mark Krenz | Date: | Mon, 23 Jan 2006 03:10:50 +0000 |
| Subject: | Fwd: [PHP] proc_open and buffer limit? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-21638@lists.php.net to get a copy of this message | ||
I asked this last night on the general mailing list and also have
asked around about it. Nobody seems to know. I normally wouldn't ask a
support quesiton on a developers mailing list, but nobody else seems to
know so I thought that perhaps a developer knows.
Why would I be running into this STDIN data size limit when using
proc_open?
I've tried setting the limits for apache to unlimited in
/etc/security/limits.conf just to see if its a system limit.
----- Forwarded message from Mark Krenz <mark@suso.org> -----
Date: Sun, 22 Jan 2006 00:25:33 +0000
From: Mark Krenz <mark@suso.org>
To: php-general@lists.php.net
Subject: [PHP] proc_open and buffer limit?
I'm using PHP 5.1.1 on Apache 2.0.54 on Gentoo Linux. I've been trying
to write a program to pass information to a program using proc_open,
however when I do, it only passes the first 65536 bytes of the stream
and then cuts off the rest. To make sure its not the program I'm trying
to send to, I tries using /bin/cat instead and get the same problem.
Below, I've included the code that I'm using, which for the most part is
from the proc_open documentation page. For testing, I'm reading from a
word dictionary which is over 2MB in size. Is there something I'm
missing about using proc_open?
-------------------------------------------------------------------------
$program = "/bin/cat";
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("file", "/tmp/error-output.txt", "a")
);
$cwd = '/var/www';
$env = array('HOME' => '/var/www');
$process = proc_open($program, $descriptorspec, $pipes, $cwd, $env);
if (is_resource($process)) {
stream_set_blocking($pipes[0], FALSE);
stream_set_blocking($pipes[1], FALSE);
$handle = fopen("/usr/share/dict/words", "r");
while (!feof($handle)) {
$input .= fread($handle, 8192);
}
fwrite($pipes[0], $input);
fclose($handle);
fclose($pipes[0]);
while (!feof($pipes[1])) {
$output .= fgets($pipes[1], 8192);
}
fclose($pipes[1]);
print "<PRE>$output</PRE><BR><BR>\n";
$return_value = proc_close($process);
echo "command returned $return_value\n";
}
-------------------------------------------------------------------------
--
Mark S. Krenz
IT Director
Suso Technology Services, Inc.
http://suso.org/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
----- End forwarded message -----
--
Mark S. Krenz
IT Director
Suso Technology Services, Inc.
http://suso.org/