|
From: Aaron B. <ab...@mi...> - 2003-04-07 13:59:53
|
Lachlan Andrew wrote:
> There *shouldn't* be a need to flush stdout unless the program exits
> abnormally (e.g. segfaults). Is the resulting file a multiple of
> 4096 bytes long? What happens if you simply pipe the output through
> more/less? Is it still truncated?
Here are two more strace's which are set to watch read()'s on FD=5 and
write()'s on FD=1. I have found that when the output is sent to the
screen (line buffered) the final write() before the open of the footer
is different than the final write() when the output is to a file or program.
output to screen (line buffered) strace.screen line # 1114:
----------------------------------
write(1, "</dd></dl>\n", 11) = 11
| 00000 3c 2f 64 64 3e 3c 2f 64 6c 3e 0a </dd></d l>.|
open("/web/pspec/htdocs/Templates/footer.html", O_RDONLY) = 5
output to file/program (4K block buffered) strace.file line # 865:
------------------------------------------
| 00fe0 20 32 36 20 4e 65 77 65 73 74 3a 20 30 34 2d 32 26 Newe
st: 04-2 |
| 00ff0 31 2d 39 38 20 4f 6c 64 65 73 74 3a 20 30 35 2d 1-98 Old
est: 05- |
open("/web/pspec/htdocs/Templates/footer.html", O_RDONLY) = 5
----
The line buffered write() data is the final result of the search (#9 of
9). This is correct since the output of results is complete and the
next item to read/write is the footer.
The block buffered write() data is not correct since the output of
results is not complete (this output is actually part of result # 7 of
9). Here the program does not complete the output of results before it
goes on to read() in the footer template. However the write() after the
read of the footer template picks up where it left off in result # 7 of
9. Is this correct behavior?
Does this help pinpoint where the bug may be? I'm not the best when it
comes to C++ so any help tracking this down would be appreciated.
Thanks,
-ab
|