Linux内核编程:Linux2.6内核源码解析_进程遍历

/*   
 *File    : test.c 
 *Author  : DavidLin      
 *Date    : 2014-12-07pm      
 *Email   : [email protected] or [email protected]      
 *world   : the city of SZ, in China      
 *Ver     : 000.000.001      
 *history :     editor      time            do      
 *          1)LinPeng       2014-12-07      created this file!      
 *          2)      
 */  

#include <linux/init.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/sched.h>

static int list_init(void)
{
    struct task_struct *task;
    
    task = NULL;
     
    for_each_process(task) {
        printk("pid = %d\n", task->pid);
    }

    return 0;
}

static void list_exit(void)
{
    printk("KERNEL MACRO: for_each_process exit\n");
}

module_init(list_init);
module_exit(list_exit);

MODULE_AUTHOR("Linpeng1577");
MODULE_DESCRIPTION("KERNEL 2.6 MACRO STUDY");
MODULE_LICENES(GPL);



郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。