kernel space module pid
本帖最后由 shihyu 于 2016-03-18 21:38 编辑#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kthread.h>
MODULE_DESCRIPTION("Hello World !!");
MODULE_AUTHOR("Bo-Yi Wu");
MODULE_LICENSE("GPL");
static int __init hello_init(void)
{
printk(KERN_INFO "Hello, world\n");
printk(KERN_INFO "The process is \"%s\" (pid %i)\n", current->comm, current->pid);
return 0;
}
static void __exit hello_exit(void)
{
printk(KERN_INFO " Goodbye The process is \"%s\" (pid %i)\n", current->comm, current->pid);
}
module_init(hello_init);
module_exit(hello_exit);
insmod hello.ko
rmmod hello.ko
[ 1815.161400] Hello, world
[ 1815.162181] The process is "insmod" (pid 3180)
[ 1820.855711]Goodbye The process is "rmmod" (pid 3182)
为什么 hello_init跟 hello_exit 的 kernel 的 pid 不同?
3180 跑完hello_init 函数就死掉?
我用 ps | grep '3180' 找不到 , 还是ps 无法查到 kernel pid ?
谢谢 为什么 hello_init跟 hello_exit 的 kernel 的 pid 不同?
因为你一个是insmod,一个是rmmod,pid当然不同啦。
页:
[1]