On Feb 10, 2008, at 2:21 AM, Paul Brannan wrote:

> Does the problem go away, or is it not apparent without sync?

I'm not sure what you're asking, but in a dozen or so runs, it doesn't  
appear to occur. However, I believe that Ruby will buffer up to 8k in  
that cases, so I probably wouldn't expect to see it.


> What happens if you explicitly flush after every write?

Calling STDOUT.flush after printf still triggers the problem, but not  
as reliably as setting .sync. However, I also see more interesting  
error cases with flush, such as

dave[RUBY3/Book 8:32:23] ruby t.rb >t.op
dave[RUBY3/Book 8:32:26] od -c t.op
0000000    1  \n   2  \n   3  \n   4  \n  \0  \0  \0  \0  \0  \0  \0  \0
*



I can't be certain, but I believe this behavior is fairly new. I see  
when when building my threading chapter, and that chapter has built  
successfully on 1.9 in the past. I suspect something has changed.



Dave