| Article 6977 of comp.lang.perl: | |
| Newsgroups: | comp.lang.perl | 
| Path: | icdoc!dds | 
| From: | dds@doc.ic.ac.uk (Diomidis Spinellis) | 
| Subject: | Re: Help Wanted with File Leak | 
| Nntp-Posting-Host: | dirty.doc.ic.ac.uk | 
| Message-ID: | <1991Oct23.153931.3666@doc.ic.ac.uk> | 
| Organization: | Dept. of Computing, Imperial College, London, England | 
| Keywords: | program file leak | 
| Date: | Wed, 23 Oct 1991 15:39:31 GMT | 
| Distribution: | comp | 
| References: | <LMJM.91Oct23135603@raquel.doc.ic.ac.uk> | 
| Lines: | 32 | 
| Content-Length: | 938 | 
In article <LMJM.91Oct23135603@raquel.doc.ic.ac.uk> lmjm@doc.ic.ac.uk (Lee M J McLoughlin) writes:
>What I want is some
>way of either tracing the open/close's (in all their various guises)
>or some way of showing the current status of file usage by the program
>at various points.
#!/bin/perl
# Dump filehandle usage
# By Diomidis Spinellis <dds@doc.ic.ac.uk> Wed Oct 23 16:34:41 BST 1991
# Example:
open(FOO, '/dev/null');
&dumpfd('main');
package dumpfd;
sub main'dumpfd {
	($package) = @_;
	local(*stab) = eval("*_$package");
	while (($key,$val) = each(%stab)) {
		{
			local(*entry) = $val;
			if ($fd = fileno entry) {
				print "Filehandle $key open as $fd\n";
			}
		}
	}
}
-- 
Diomidis Spinellis                  Internet:                 dds@doc.ic.ac.uk
Department of Computing             UUCP:                    ...!ukc!icdoc!dds
Imperial College, London SW7        #include "/dev/tty"
 Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.
Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.