I'm trying to work up a minimal example to show the problem - the issue I've got now is that when I make the example very minimal, the problem goes away. :)
You may be right that it's a buffering problem though: I've written an example script which prints a line from Perl, then a line from C, then a line from Perl. On my Mac the lines appear in the file in the expected way, but on the Linux machine where I've originally found the problem, they appear in this order:
and putting a fflush(stdout) in the right place solves that problem...
...ok, so let's try doing that in the real script... success! Hooray!
Triple++ (if I could) to cdarke, and many thanks.
Best wishes, andye