Friday, October 3, 2008

Difference between stdout and stderr

stdout and stderr is defaulted to the console.  It means both error messages and normal output will be shown on the same device.  Why do we differentiate stdout and stderr in the first place?

Output to stdout is buffered.  In other words, output may take some time before it will appear in the destination device (console typically).  In contrast, stderr is unbuffered.  It means output will appear in the destination device immediately after the write call.  That's why error message should be written to stderr instead of stdout.

No comments: