首页 > 系统服务 > 详细

Linux获取进程中变量

时间:2015-06-21 15:39:22      阅读:183      评论:0      收藏:0      [点我收藏+]

列出所有进程

技术分享
 1 #include <linux/kernel.h>
 2 #include <linux/module.h>
 3 #include <linux/init.h>
 4 #include <linux/sched.h>
 5 #include <linux/list.h>
 6 
 7 static __init int print_pid(void)
 8 {
 9     struct task_struct *task,*p;
10     struct list_head *pos;
11     int count=0;
12     printk("Hello,let begin\n");
13     task = &init_task;
14     list_for_each(pos,&task->tasks)
15     {
16         p = list_entry(pos, struct task_struct, tasks);
17         count++;
18         printk("%d---->%s-->%X\n",p->pid,p->comm, p->state);
19     }
20     printk("the number of process is:%d\n",count);
21     return 0;
22 }
23 
24 static __exit void print_exit(void)
25 {
26     printk("<0>end!\n");
27 }
28 module_init(print_pid);
29 module_exit(print_exit);
View Code

 

Linux获取进程中变量

原文:http://www.cnblogs.com/macinchang/p/4591918.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!