Windows solution: Download MS TechNet::SysInternals::Handle at https://download.sysinternals.com/files/Handle.zip. Unzip into same directory as the script below, or into PATH if you want it long term
use warnings; use strict; sub ph { print `handle -nobanner -u -p $$`; # shows handle id (hex), t +ype (file), mode (rw-), and filename print `handle -nobanner -u blah`; # shows exe, pid, type, ow +ner, id (hex), filename print `handle -nobanner -s -p $$`; # shows summary of all the + different handle types open by that process print 'HIT ENTER'; <STDIN>; } local $\ = $/; print $$; ph(); open my $wr, '>', 'blah'; ph(); open my $rd, '<', 'blah'; ph(); open my $wrnul, '>', 'NUL'; open my $rdnul, '<', 'NUL'; close $wr; close $rd; ph();
It turns out I had recently (last week) had a problem with EU::MM's dmake distdir && ... && dmake realclean not being able to delete the distribution directory because something (I still don't know what) was holding the directory open. In fact, whatever it was wouldn't let me even delete it after closing all my cmd.exe and explorer.exe windows -- I had to reboot to get it. Unfortunately, my search-foo wasn't good enough last week to find handle.exe, so I didn't figure out what I'd done to hold it open. Thanks to the lsof hints in this thread, today I was able to find lsof for windows => handle.exe and the similar GUI-based TechNet::SysInternals::Process Explorer. So ++thanks for all the contributors to this thread
In reply to Re: A way to report open file handles a Perl script has open?
by pryrt
in thread A way to report open file handles a Perl script has open?
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |