sigar/exp/proc_args.pl

32 lines
500 B
Perl
Raw Normal View History

2005-09-29 08:00:59 +08:00
#!perl
use strict;
my $match = $ARGV[0];
2005-10-08 07:53:00 +08:00
my $proc = "/proc";
opendir DH, $proc or die;
chdir $proc;
2005-09-29 08:00:59 +08:00
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;
}
2005-10-08 07:53:00 +08:00
print "-------------------------------\n";
my $i=0;
print "pid=$pid\n";
for my $arg (@cmdline) {
print "$i='$arg'\n";
$i++;
}
2005-09-29 08:00:59 +08:00
}
closedir DH;