Messages in this thread | | | Date | Sat, 19 Jun 1999 23:00:21 +0200 | From | Pavel Machek <> | Subject | Re: waitpid advice ? (killing off a kernel thread) |
| |
Hi!
> (not on list, please CC me) > > I am working on the USB drivers trying to get the hub and the host > controller (uhci/ohci/ohci-hcd) drivers to unload correctly. The problem > is that the drivers have threads running that are not dying before I start > deallocating resources. > > currently I am trying the following code (from hub.c): > =========begin code snip============ > void cleanup_module(void) > { > if (khubd_pid >= 0) > { > int pid; > kill_proc(khubd_pid, SIGTERM, 1); > pid=waitpid(khubd_pid, NULL, __WCHILD); > if (pid!=khubd_pid) > printk("waitpid filed," > "khubd_pid=%i,retpid=%i\n",khubd_pid,pid); > } > usb_deregister(&hub_driver); > } > =========end code snip============ > > Sometimes it works. Othertimes I get the waitpid filed (ok, so I typed > 'failed' wrong...) message, promptly followed by a kernel oops.
Hmm, you might do something like while (sys_kill(pid, SIGTERM) != -1) schedule();
It is ugly because it depends on PID not being reused, but it might work after all.
Wait. In what context process does cleanup_module() code run? It is probably not safe to do blocking call in idle task or something similary bad.
Pavel PS: Is someone working on audio-for-USB? -- I'm really pavel@ucw.cz. Look at http://195.113.31.123/~pavel. Pavel Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |