make output same as sigar_proc_args.c

This commit is contained in:
Doug MacEachern 2005-10-07 23:53:00 +00:00
parent cd8cab425e
commit 0c78750f61
1 changed files with 12 additions and 3 deletions

View File

@ -4,8 +4,9 @@ use strict;
my $match = $ARGV[0]; my $match = $ARGV[0];
opendir DH, "/proc" or die; my $proc = "/proc";
chdir "/proc"; opendir DH, $proc or die;
chdir $proc;
local $/; local $/;
while (my $pid = readdir DH) { while (my $pid = readdir DH) {
@ -16,7 +17,15 @@ while (my $pid = readdir DH) {
if ($match) { if ($match) {
next unless grep { /$match/o } @cmdline; next unless grep { /$match/o } @cmdline;
} }
print "(pid=$pid) ", (map { "=>$_<=" } @cmdline), "\n";
print "-------------------------------\n";
my $i=0;
print "pid=$pid\n";
for my $arg (@cmdline) {
print "$i='$arg'\n";
$i++;
}
} }
closedir DH; closedir DH;