Loosing signals even with sigqueue


 
Thread Tools Search this Thread
Top Forums Programming Loosing signals even with sigqueue
# 1  
Old 12-12-2006
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..
# 2  
Old 12-12-2006
You didn't post the code surrounding your sigqueue call. The call should fail with EAGAIN if the queue is currently full.
# 3  
Old 12-12-2006
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  
Old 12-12-2006
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  
Old 12-12-2006
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  
Old 12-12-2006
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  
Old 12-13-2006
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 ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Loosing connection after authentication

Hi! I am having a problem when logging in on a solaris 10 server, after typing one or two commands, I lose connectivity, with the following message: server unexpectedly closed network connection I have checked the following: grep `uname -n` /etc/inet/hosts /etc/inet/ipnodes... (8 Replies)
Discussion started by: fretagi
8 Replies

2. UNIX and Linux Applications

Samba loosing SID UID mapping

Hi all, I don't know how many times I've setup samba shares, but... It's been a while since the last time. The SID UID maps used to always seem random. I.E. if I had to move the data to another box, I'd have to note all of the SID / UID relations and write scripts to convert them on the new... (0 Replies)
Discussion started by: mph
0 Replies

3. UNIX for Dummies Questions & Answers

How can i sort a .txt file without loosing the header information?

Hi, I'm trying to sort 2 different .txt tab delimited files with the command line: sort -k 1b,1 inputfile > outputfile But doing that i'm also sorting the header (that ends at the end of my file). How can i sort a .txt file without sorting the header but conserving the header in the... (3 Replies)
Discussion started by: alisrpp
3 Replies

4. Homework & Coursework Questions

Loosing formatting when echoing an awk script

1. The problem statement, all variables and given/known data: When I echo out the output of my awk script I loose the formatting that I set in my awk script (it should be in a table format). 2. Relevant commands, code, scripts, algorithms: 3. The attempts at a solution (include all... (2 Replies)
Discussion started by: ROFL
2 Replies

5. SCO

SCO box loosing network connection

Hello, We have a SCO box running OpenServer 5.0.5. This has our business software on it (15 users connecting via terminal emulator (ansio lite)) which has been running for about 12-15yrs strong! Within the past 6-8 months, at random times of the day, we've been loosing connection to this box. ... (8 Replies)
Discussion started by: rpcbrielle
8 Replies

6. What is on Your Mind?

You know your on the brink of loosing it when.....

you spend an entire day with scripting nightmares and go to bed real late in the early morning hrs to wake up to your gf asking you a question and your only answer is "It's in the script" LMAO Happened to me this morning would you believe that?? My daughter is 10yrs old and my gf wanted to check... (3 Replies)
Discussion started by: phpfreak
3 Replies

7. Shell Programming and Scripting

Replacing Carriage returns without loosing EOL

Hello, I have read a few threads on this subject and tried a few things out, but still come up short. There was one good example, then the last reply was something to the effect of 'Use Sed' & 'Read a book'... Well I read a bunch of online tutorials on sed, awk, tr, but still can't get the... (2 Replies)
Discussion started by: Majiktom
2 Replies

8. Shell Programming and Scripting

replace ascii chars without loosing it.

Hi, Can some one tell, how to replace ascii non printable TAB from the while to something, then later on replace it back to TAB. Basciallz we do bulk data processing, our processin treats TAB as new field , So I thought we can replace it with something and later on revert it. TIA (4 Replies)
Discussion started by: braindrain
4 Replies

9. UNIX for Dummies Questions & Answers

How to install FreeBSD without loosing my data?

hi. I am newbie in Unix. I wanted to install Free BSD 5.2.1 to my computer which winXp was already installed. But i couldn't. I chose Standard. Then it said you are going to use dos style fdisk partitioning. Then a window displayed begining like this. WARNING: A geometry of 155127/16/63 for... (0 Replies)
Discussion started by: sualcavab
0 Replies

10. UNIX for Dummies Questions & Answers

Linux without loosing Win9x

If you wan't to try Linux but don't want to lose Micro$oft Win, 3 basic options. You can buy a new Disk ( wich aren't as expensive as they were) and install it there. You can partition your disk so that you'll be able to boot under win or linux. Or you can run VMware, wich is a great Virtual... (2 Replies)
Discussion started by: merlinpr
2 Replies
Login or Register to Ask a Question