jonleighton/poltergeist — pull request #446 by tmwh (2014-01-25 23:38:17+00:00)
Title: Clean up fd after use

If application is using many sessions and runs for a long time it fails with Errno::EMFile too many open files error. It is happening because STDOUT.dup creating new file descriptor, but STDOUT.reopen only reassociates fd#1 with given filepath but not removes created file descriptor.
This pr fixes the problem.