pipe READ_FIFO, WRITE_FIFO; open STDOUT_SAVED, ">&STDOUT"; open STDOUT, ">&WRITE_FIFO"; component->display(); #displays the component to STDOUT->WRITE_FIFO open STDOUT, ">&STDOUT_SAVED"; close WRITE_FIFO; $content=""; while (<READ_FIFO>) { $content .= $_; } close READ_FIFO; return $content;
The problem is that there appears to be a 4k (4096B) buffer limit. This solution works great with small components (text less than 4k), but for longer ones, the code hangs on the "component->display()". It basically fills up the buffer and waits for it to be cleared. But since I'm doing this all in one process, it never gets cleared :-)
Is there a way to increase the buffer size?
BTW, I'm not married to this approach, but it seemed the cheapest. I thought storing up a buffer of text in a FIFO was cheaper than forking a process. I also don't want to use a file--try to avoid the overhead and headaches involved with temporary files (especially accross multiple platforms).
Suggestions on other ways to catch the STDOUT to a variable are also welcome! TIA
In reply to FIFO buffer size limits by kostya
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |