Fixed return code check after dup2