ficoos/cpopen — pull request #22 by nirs (2014-02-15 22:56:04+00:00)
Title: __init__: Keep the original error when createProcess failed

The original code was trying to raise the original error, assuming that
closing fds cannot fail. However, if closing on of the fds do fail, the
error would hide the original error raised by createProcess, making it
harder to debug.

This patch fix error handling after createProcess failure, by keeping
the original exception and raising it after closing fds, ignoring error
in os.close(). Similar code exists in Python 2.7, so this code is needed
only for Python 2.6.

The patch does not ensure that all the unused parent side fds are closed
in normal conditions. The previous code was using finally to ensure that
the first fd is closed, but error when closing one fd would leave the
next fds open.