Re: daemonize and allow_signal (was: Re: Re: Re: kernel thread blocked in sock_recvmsg() not kill-able)

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

 



El dc 21 de 12 del 2005 a les 17:18 +0700, en/na Mulyadi Santosa va
escriure: 
> Hello Toni ...
> 
> > conclusion, the real problem in my example was that i'm
> > deamonize()'ing after allow_signal(SIGKILL) funtion, and as i've seen
> > in
> > kernel/exit.c#L272:
> > this two lines must be switched... and everything works fine ;)
> 
> Hehehe :) I just read those functions closely too and I realize what the 
> mistake is :)
> 
> However, does that make blocking version sock_recvmsg() works?
> 

yes, it works as i expected, with no need to msleep() and checking for
signals after the sock_recvmsg() in the main loop (the function
sock_recvmsg exits with a error code -512 after a SIGKILL):

for (;;)
{
	memset(&buf, 0, bufsize);
	if (sock->sk==NULL) return 0;

	iov.iov_base = buf;
	iov.iov_len = len;

	msg.msg_flags = 0;
	msg.msg_name = addr;
	msg.msg_namelen  = sizeof(struct sockaddr_in);
	msg.msg_control = NULL;
	msg.msg_controllen = 0;
	msg.msg_iov = &iov;
	msg.msg_iovlen = 1;
	msg.msg_control = NULL;

	oldfs = get_fs();
	set_fs(KERNEL_DS);
	size = sock_recvmsg(sock,&msg,len,msg.msg_flags);
	set_fs(oldfs);

	if (signal_pending(current))
		break;

	if (size < 0)
		printk(KERN_INFO "sock_recvmsg error = %d\n", size);
	else {
		printk(KERN_INFO "received %d bytes\n", size);
		/* data processing */
	}
}


and that's all! ;)

regards,

toni

> regards
> 
> Mulyadi
> 

-- 
toni <agar9938@xxxxxxxxxxxxxxxxxx>


--
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