Reputation: 6385
How to tell from Linux process2
whether I am given standard output or error from the previous process. Is it possible, to tell inside process2, whether particular line comes from stderr or stout
bash>process1 2>&1 | process2
So I guess by John's answer, it is "no". Then I am guessing, one way to handle this, is to inject specific prefixes for each line inside process1:
1: <line>
for stdout
2: <line>
for stderr
then I can inspect them in process2. Is this the normal thing to do?
Upvotes: 0
Views: 73
Reputation: 249153
No, it is not possible. You can differentiate stdin from a terminal by isatty()
but not what sort of stream the input came from in the way you want.
Upvotes: 2