Zero-knock cowhide: Linux2.6 kernel source code parsing _ process traversal, zero-knock linux2.6

Source: Internet
Author: User

Zero-knock cowhide: Linux2.6 kernel source code parsing _ process traversal, zero-knock linux2.6

/*    *File    : test.c  *Author  : DavidLin       *Date    : 2014-12-07pm       *Email   : linpeng1577@163.com or linpeng1577@gmail.com       *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);

For the Makefile file and test of this routine, refer to the previous blog:

Linux Kernel programming: Starting from hello world-(1) _ C file writing

Linux Kernel programming: Starting from hello world-(2) _ Makefile file writing

Linux Kernel programming: Starting from hello world-(3) _ run

1. However, tail-n 3/var/log/messages can be changed to tail-n 100/var/log/messages;

2. ps-el lists the processes.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.