码迷,mamicode.com
首页 > 系统相关 > 详细

Linux获取进程中变量

时间:2015-06-21 15:42:38      阅读:260      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!