If I have progA | progB, then can I make some progB executable (in any language) which will know the return code of progA?
EDIT:
if the answer is platform dependent, then I would like to know the answers for all platforms since this is a question out of sheer curiousity. However, POSIX machines (linux in particular) are what I use most.
I’m pretty sure the answer is no for POSIX. The two main arguments against it are:
progBto determine the PID of theprogAprocess on the other side of the pipe (although there are system-dependent ways around this – on Linux, you can use the pipe’s inode number to find the process keeping the other end open in most cases, this question will get you started).progBhad the PID ofprogA, it could not receive its exit status since only the parent process ofprogA(in this case probably your shell) canwaitfor it. As far as I can tell, there is no way around this restriction.