Go Back   The UNIX and Linux Forums > Top Forums > Programming
.
google site



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
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 05:48 AM..
Sponsored Links
  #2 (permalink)  
Old 12-12-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,148
You didn't post the code surrounding your sigqueue call. The call should fail with EAGAIN if the queue is currently full.
  #3 (permalink)  
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 11:18 AM..
  #4 (permalink)  
Old 12-12-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 2,448
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.
  #5 (permalink)  
Old 12-12-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,148
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.
  #6 (permalink)  
Old 12-12-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 2,448
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.
  #7 (permalink)  
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 ?
Sponsored Links
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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 07:28 AM
replace ascii chars without loosing it. braindrain Shell Programming and Scripting 4 02-01-2006 10:02 AM
How to install FreeBSD without loosing my data? sualcavab UNIX for Dummies Questions & Answers 0 12-05-2005 04:02 AM
Linux without loosing Win9x merlinpr UNIX for Dummies Questions & Answers 2 06-27-2001 04:48 PM



All times are GMT -4. The time now is 06:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0