saltstack/salt — pull request #2598 by s0undt3ch (2012-11-16 23:26:18+00:00)
Title: Fix #2509

On some of the [huge debug data(issues/2509 and cherry-pick/CLOEXEC builds)](https://travis-ci.org/s0undt3ch/salt/builds) gathered from the past days I've noticed some huge use of FD's.

An effort was made to close FD's as soon as possible. This impacts python 2.6 even more because `subprocess.Popen` uses `select` instead of `poll` limiting the number of FD's `subprocess.Popen` can handle to 1024.

The tests are all passing and we should add documentation to let users know about `salt.utils.mkstemp()` and `salt.utils.fopen()`, major participants in this fix.

We should not forget that by using `salt.utils.fopen()` we're changing the flags on the file descriptors(something that `subprocess.Popen` in python >= 2.7 also does, hence not having problems), so we can detect any future issues regarding it.