The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replacing Carriage returns without loosing EOL Majiktom Shell Programming and Scripting 2 03-08-2008 04:28 AM
replace ascii chars without loosing it. braindrain Shell Programming and Scripting 4 02-01-2006 07:02 AM
How to install FreeBSD without loosing my data? sualcavab UNIX for Dummies Questions & Answers 0 12-05-2005 01:02 AM
Linux without loosing Win9x merlinpr UNIX for Dummies Questions & Answers 2 06-27-2001 12:48 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 12-12-2006
Registered User
 

Join Date: Nov 2006
Posts: 17
Loosing signals even with sigqueue

Hi everyone,

I have a process that forks many times.At a random time point the children must send a SIGUSR1 to the parent.To do that I'm using a pair of sigaction & sigqueue.However many signals are getting lost.
Here are some code segments:
a)sigaction
Code:
sigset_t mask_set;	/* used to set a signal masking set. */
	sigfillset(&mask_set);


	struct sigaction act;
	act.sa_sigaction=catch_usr1;
	act.sa_mask=mask_set;
	act.sa_flags=SA_SIGINFO | SA_RESTART;

	sigaction(SIGUSR1,&act,NULL);
b)signal handler

Code:
void catch_usr1(int sig,siginfo_t *a,void *b )
{
	sigcount++;
	if (readers>0)
		readers--;
	else
		writing=false;
	printf("[LOG] Signal received. Readers now: %d Signal counter: %d\n",readers,sigcount);
	fflush(stdout);
}
c)sigqueue

Code:
tmp=sigqueue(getppid(),SIGUSR1,vsig);
Can anybody find an error

Last edited by jonas.gabriel; 12-12-2006 at 02:48 AM.
Reply With Quote
Forum Sponsor
  #2  
Old 12-12-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,616
You didn't post the code surrounding your sigqueue call. The call should fail with EAGAIN if the queue is currently full.
Reply With Quote
  #3  
Old 12-12-2006
Registered User
 

Join Date: Nov 2006
Posts: 17
I just have this simple statements
Code:
tmp=sigqueue(getppid(),SIGUSR1,vsig);
close(handler.connfd);
printf("SERVER CHILD for %d: Out.Sigqueue returned %d\n",handler.id>0?handler.id:-handler.id,tmp);
fflush(stdout);
return 0;
I redirect my output to a file.The tmp variable has always the value 0.

Last edited by jonas.gabriel; 12-12-2006 at 08:18 AM.
Reply With Quote
  #4  
Old 12-12-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 979
Quote:
Originally Posted by Perderabo
You didn't post the code surrounding your sigqueue call. The call should fail with EAGAIN if the queue is currently full.
It can fail with an error status, but isn't required to. This has caused some rarely-seen and bothersome bugs on a few platforms.
Reply With Quote
  #5  
Old 12-12-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,616
Quote:
Originally Posted by Corona688
It can fail with an error status, but isn't required to. This has caused some rarely-seen and bothersome bugs on a few platforms.
Excuse me? If SA_SIGINFO is set, either the signal must be successfully queued or sigqueue() must return an error. And without SA_SIGINFO, sigqueue must behave at least like kill() and deliver the signal if it is not pending. This behavior is required by the Posix standard:
Quote:
Upon successful completion, the specified signal will have been queued, and the sigqueue() function returns a value of zero. Otherwise, the function returns a value of -1 and sets errno to indicate the error.
Reply With Quote
  #6  
Old 12-12-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 979
Apparently the linux kernel maintainers were misinformed, then. An old design flaw in the linuxthreads system is that, if the signal queue overflows and it's never informed of it, causing thread termination signals to stop being delivered, resulting in something very odd -- zombie threads. They couldn't fix it as it was a design flaw rather than a bug, and the kernel maintainers insisted that error status was not required. nptl doesn't have the same issues fortunately.
Reply With Quote
  #7  
Old 12-13-2006
Registered User
 

Join Date: Nov 2006
Posts: 17
So it isn't a fault of mine. I'm working already on a solution based on sockets using select.Should I reject signals as solution to my problem ? Reability of delivery is important to me.What is your opinion ?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0