Helllo, I tried writing a simple kernel module which starts a kernel thread. When I perform insmod to this module, I see that the kernel thread is started and enters "sleep" mode (I see it by "ps -aux"). When I try to remove the module by "rmmod" it hangs. Trying "rmmod -f" gives an error: "ERROR: Removing 'kthread1': Device or resource busy" and the module is **not** removed. Any idea what am I missing here ? should I add/change something in the cleaning up procedure ? The code is here below; it is short (80 lines); Any help will be more than welcomed. --- #include <linux/version.h> #include <linux/module.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h> #include <linux/sched.h> #include <linux/string.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/kmod.h> #include <asm/uaccess.h> #include <asm/system.h> #include <linux/ip.h> #include <linux/tcp.h> #include <linux/in.h> #include <linux/kernel.h> #include <linux/kthread.h> #include <linux/wait.h> struct task_struct *p; static DECLARE_WAIT_QUEUE_HEAD(wq); static int myKernlThread(void *arg) { int flag=1; allow_signal(SIGKILL); allow_signal(SIGTERM); allow_signal(SIGINT); wait_event_interruptible(wq,flag==0); return 0; } int init(void) { void *data; p = kthread_run(myKernlThread,data,"myKTernelThread"); if (IS_ERR(p)) { printk("could not create thread\n"); return -1; } return 0; } static int __init kthread_init(void) { init(); return 0; } ////////////////////////////////////////////////////////////////////////////// static void __exit kthread_exit(void) { if (p) kthread_stop(p); p=NULL; } module_init(kthread_init) module_exit(kthread_exit) MODULE_AUTHOR("IB"); MODULE_DESCRIPTION("kthread test module"); MODULE_LICENSE("GPL"); Regards, Ian -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ