2005-09-29 08:00:59 +08:00
|
|
|
#!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;
|
|
|
|
}
|
2005-10-01 05:36:34 +08:00
|
|
|
print "(pid=$pid) ", (map { "=>$_<=" } @cmdline), "\n";
|
2005-09-29 08:00:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
closedir DH;
|