2 ms·
A disadvantage of separate stdout and stderr streams is matching of errors to the corresponding resulting output.
by cpeterso 13y ago
A disadvantage of separate stdout and stderr streams is matching of errors to the corresponding resulting output.
- jewel 13y agoWhen this is important, you can make it so that stdout and stderr are the same stream, via a variety of methods. With bash this is done with 2>&1, as in: command 2>&1
- bazzargh 13y agoWhile that makes them the same stream, it doesn't actually solve the problem. Many systems will write to stdout buffered, but stderr unbuffered, so that writes are visible when the program crashes. Redirecting streams at the shell level doesn't stop application level buffering ruining your day. Having said that, GP's request is pretty niche, it's only useful when the program uses stdout (not a gui, web etc) and is doing work that might write to stderr while it's writing to stdout (so no summary report generators, long running physics simulations etc)
- fit2rule 13y agoNot if your logmsg() function prepends a timestamp to each message. Then its just a matter of glomming the output FD's, piping through sort, and .. problem solved.