#include #include #include #include static char modname[] = "pid.ko"; static struct task_struct *mytask; static struct task_struct *parent; static int __init init(void) { mytask = current; printk(KERN_ALERT "%s loaded by %s (%d)\n", modname, mytask->comm, mytask->pid); parent = mytask->parent; while (mytask->pid != parent->pid) { printk(KERN_ALERT "current: %s (%d) - parent: %s (%d)\n", mytask->comm, mytask->pid, parent->comm, parent->pid); mytask = mytask->parent; parent = mytask->parent; } return 0; } static void __exit exit(void) { printk(KERN_ALERT "%s unloaded\n", modname); } module_init(init); module_exit(exit); MODULE_LICENSE("GPL");