#!/usr/bin/perl
use strict;
use warnings;
#usage: process_grep.pl ProcessName
exit( main(@ARGV) );
#!/usr/bin/perl
use strict;
use warnings;
#usage: process_grep.pl ProcessName
exit( main(@ARGV) );
sub main {
my $Phash;
my $ProcessName=shift;
my $PROC_DIR=”/proc”;
chdir $PROC_DIR;
my @pids=glob “[0-9]*”;
for my $pid (@pids) {
open( FH, “$pid/cmdline” ) or die “Can’t $pid file $!”;
$Phash->{$pid}=$_ while <FH>;
}
delete $Phash->
© 版权声明
文章版权归作者所有,未经允许请勿转载。