文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>显示某个进程包含特定线程名字的线程

显示某个进程包含特定线程名字的线程

时间:2010-08-18  来源:wylhistory

#!/data/busybox sh if [ $# -lt 2 ];then echo "Usage $0 therad name" exit fi thread=$1 name=`echo $2 | /data/busybox  sed  's/[^A-Z|a-z]//g'` echo "the thread $thread,the name $name" if [ ! -e /proc/$thread ];then echo "no such thread :$thread" exit fi
threads=`cat /proc/$thread/status | /data/busybox grep Threads | /data/busybox  awk '{print $2}'` echo "the threads is $threads" let i=0; let num=0; basethread=$thread; topthread=`ps | /data/busybox  grep -v ps    | /data/busybox  tail -n 1 | /data/busybox awk '{print $2}'` let diff=$topthread-$basethread echo "the topthread $topthread,diff is $diff" while [ $i -lt $diff ]; do let thread=$basethread+$i if [ ! -e /proc/$thread ];then let i=$i+1 continue; fi target=`cat /proc/$thread/status | /data/busybox  grep Name | /data/busybox  awk -F ":" '{print $2}' | /data/busybox  sed  's/[^A-Z|a-z]//g'` if [ $target == $name ];then echo "Success to find it,the pid is $thread" break; fi tgid=`cat /proc/$thread/status  | /data/busybox  grep Tgid | /data/busybox  awk '{print $2}'` if [ $tgid -eq $basethread ];then let num=$num+1; fi if [ $num -ge $threads ];then echo "I have search for all the threads" break; fi let i=$i+1 done echo "at last the i is $i,the num is $num,the threads is $threads,thread is $thread"


用法: ./show_thread.sh  1882 pvplayer 第一个参数是通过ps看到的某个你需要关心的进程; 第二个参数是我们要查找的名字叫做pvplayer的线程,这个名字需要去掉里面的空格,并且是区分大小写的;
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载