网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 perl查找进程pid的例子
范文
    主要是利用查找/proc目录下的相关文件进行查找.
    ?12345678910111213141516171819202122 #!/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->{$$}; for my $pid ( keys %$phash ) { print $pid, \n if $phash->{$pid} =~ /$processname/; } return 0; }
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/26 2:56:56