#include #include #include #include MODULE_DESCRIPTION("Process list module"); MODULE_AUTHOR("so"); MODULE_LICENSE("GPL"); #define LOG_LEVEL KERN_WARNING static int my_hello_init(void) { struct task_struct *p; printk(KERN_ALERT "Entering process list module!\n"); printk(KERN_ALERT "Current process: pid = %d; comm = %s\n", current->pid, current->comm); printk(KERN_ALERT "\nProcess list:\n\n"); for_each_process(p) { printk(KERN_ALERT "pid = %d; comm = %s\n", p->pid, p->comm); } return 0; } static void hello_exit(void) { printk(LOG_LEVEL "Exiting process list module!\n"); } module_init(my_hello_init); module_exit(hello_exit);