For bash, there's a convenient special array: PIPESTATUS. The return code for myapp
would be in ${PIPESTATUS[0]} and so on.
zsh has a roughly identical method.
There's also a rather more annoying, hacky way to do it in strict bourne shells that you can read about in the comp.unix.shell FAQ.