_setup_pipes: close unnecessary duplicate fds