On Jul 13, 2004, at 1:06 AM, Sisyphus wrote:
#$| = 1; #makes no difference
$| has no effect on stdio's printf(), only on *perl*'s print ops. if you want $| to affect print statements from your xs code, you need to use perlio from your xs code.
if you cannot change the c code to use perlio (e.g., you're wrapping a C library), then you need to set the stdio stdout stream to be unbuffered, or at the very least, line buffered. do this before getting into your C code, preferably.
man setbuffer man setlinebuf # probably on the same manpage
/* set stdout unbuffered (is a performance hit!) */ setbuffer (stdout, NULL, 0);
/* tell stdout to fflush() after every '\n' */ setlinebuf (stdout);
-- "it's hard to be eventful when you have this much style." - me, rationalizing yet another night of sitting at home.