my $procdir = '/proc'; opendir(PROCDIR,"/proc") or die("Can't open proc..."); my @procs; while(defined($file = readdir(PROCDIR))){ if ($file =~ /^[0-9]/) { if (-e '/proc/'.$file.'/fd/'){ push @procs,$file; } } } closedir(PROCDIR); foreach(@procs){ my $pid = $_; my $fdpath = '/proc/'.$_."/fd/"; opendir(DIR,$fdpath); while(defined($file = readdir(DIR))){ if (-l $fdpath.$file){ if(defined($act = readlink($fdpath.$file))){ if ($act =~ /^//){ print "[PID:$pid]",$act,"n"; } } } } closedir(DIR); }
Perhaps someone else will find this useful :-) It's not fast, it's not nice, but it does the job :-)
blog comments powered by Disqus