{ cmd0; echo $? > status0; } | { cmd1; echo $? > status1; } | cmd2

# mkfifo fifo; command2 <fifo & command1 >fifo; echo "$?"
