Based on BiPipe from MistPlayer branch v2: fix dup2 of wrong fd, fix invalid fd debug print
Edited patch because of context change due to: commit 28548f35b0 Author: Thulinma <jaron@vietors.com> Date: Tue Aug 14 20:53:05 2012 +0200 Do not report part-termination of processes.
28548f35b0