Re: kernel thread blocked in sock_recvmsg() not kill-able

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello Toni..

> 	size = sock_recvmsg(kthread->sock,&msg,len,0);

try to pass MSG_DONTWAIT as flag/last parameter (defined in 
linux/socket.h) so it becomes non blocking read operation. maybe this 
won't solve your problem, but at least it can check whether you 
actually receive the packet or not.

BTW, how big is "len"?

> when the module is unloaded, the module remains blocked until a
> datagram is received and the 'main loop' ends

I think this happens as the consequences of blocking operation awaiting 
the data as many as you want. 

> 	err = kill_proc(kthread->thread->pid, SIGKILL, 1);

The problem is, AFAIK, pending signal is checked and its handler is 
executed when a task is going to switch back to user space. And as you 
know, kernel thread never returns to user space. 

IIRC, in 2.6.x, you should use provided kthread helper function. take a 
look on linux/kthread.h inside kernel tree. Basically, it uses 
completion to "signal" a thread that it is allowed to finish.

As always, somebody please CMIIW

regards

Mulyadi


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux