Re: BASH Redirect (STDOUT & STDERR) Syncing
Hal Vaughan <email@example.com> writes:
> I'm running a Perl script and redirecting the output to a file, and
> redirecting STDERR to the same file, like this:
> myprog >capture.txt 2>&1
> And I've noticed that the error output is not in sync with STDOUT. Is there
> any way, when doing a redirect like this, to synchronize the output, so I can
> tell when (in relation to STDOUT) the error messages were output?
this is a wild guess coming now, but I'm posting it just to compare it
to what finally comes out as being right.
They aren't 'in sync', as you call it, presumably because of the
output buffering done in Perl, where one channel, either stdout or
stdin, receives significant less output than the other and hence
flushes more seldom.
IIRC, there's something like an operation $| or similar, which I think
was called 'hot pipe' or similar, and which should make the
corresponding output stream unbuffered.
If all this is at least almost right, could be it even suffices,
together with some googling, to resolve the issue. But I'm not sure.