script to grep/print argv from /proc

This commit is contained in:
Doug MacEachern 2005-09-29 00:00:59 +00:00
parent b3fa69ab5c
commit a2774e75a8

22
exp/proc_args.pl Normal file
View File

@ -0,0 +1,22 @@
#!perl
use strict;
my $match = $ARGV[0];
opendir DH, "/proc" or die;
chdir "/proc";
local $/;
while (my $pid = readdir DH) {
next unless $pid =~ /^\d+$/;
open FH, "$pid/cmdline" or next;
my(@cmdline) = split /\000/, <FH>;
close FH;
if ($match) {
next unless grep { /$match/o } @cmdline;
}
print "$pid=[", (map { "=>$_<=" } @cmdline), "]\n";
}
closedir DH;