How to find all open STDERR and STDOUT dups?by tlm (Prior)
|on Mar 31, 2009 at 17:55 UTC||Need Help??|
tlm has asked for the
wisdom of the Perl Monks concerning the following question:
Hi everyone. I just spent a very long time tracking down a bug that boiled down to some lingering open file handles, all duplicates of STDERR, that were causing an HTTP connection to remain open longer than it should have.
These "rogue" filehandles had been opened by a module that my code did not load explicitly. In fact, I was not even aware that my code was using this module at all, since it comes in at the end of a long dependency chain...
To avoid this sort of bug in the future, I'm looking for a way for my code to find all the open non-lexical file handles that are duplicates of either STDOUT or STDERR.
Before I go off on a clueless hacking of the symbol table, or some other equally harebrained scheme, I thought I'd ask here if anyone knew of a good way to do what I'm trying to do.
Many thanks in advance!
the lowliest monk