LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-13-2011, 04:40 AM   #1
apurvajalit
LQ Newbie
 
Registered: Oct 2011
Posts: 1

Rep: Reputation: Disabled
Weird behaviour of sigwait


I am using sigwait to block my thread for some signals. These signals have been added in the sigs set. AS per the doc sigwait is supposed to wait only for the signals passed to it as a set in the argument and is not supposed to change th signal mask of that thread.. But for some reason i dont know, it is changing the signal mask of the thread. It is blocking all signals other than the ones in sigs. I dont wish this to happen. Can someone help me with the same. Thanx in advance

The code snippet:

sigset_t sigs;
int sig_recvd;
sigset_t old_mask;
sigemptyset(&sigs);
sigaddset(&sigs, SIGUSR1);
sigaddset(&sigs, SIGTERM);
sigaddset(&sigs, SIGHUP);
sigaddset(&sigs, SIGINT);
sigaddset(&sigs, SIGPIPE);
sigaddset(&sigs, SIGCHLD);

sigprocmask(SIG_BLOCK, &sigs, &old_mask);

do
{

sigwait(&sigs, &sig_recvd);
//Switch for some signal handling

} while(1);

Sigblk before sigwait: 0000000080014203
Sigblk during sigwait: fffffffefffabcfc
 
Old 10-13-2011, 11:06 AM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
It sounds like you want the handlers for signals that aren't being sigwaited on to execute even while sigwait is blocked. For this to happen sigwait would have to unblock, handle the signal, then block again. You might instead just sigwait on all signals in ~old_mask and have a while loop that only breaks if sig_recvd has a bit set for one of the signals you're waiting for.
Kevin Barry

Last edited by ta0kira; 10-13-2011 at 11:08 AM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
weird ps/2 mouse behaviour macbeth8 Slackware 3 04-05-2008 10:34 AM
weird gzip behaviour? vlkplk Debian 3 02-22-2008 03:26 AM
Weird behaviour when trying to connect to LQ bigjohn LQ Suggestions & Feedback 2 03-11-2006 10:27 AM
9.3 weird behaviour ????? bigjohn SUSE / openSUSE 9 07-06-2005 05:44 AM
weird slit behaviour RaulConQ Linux - Software 7 10-31-2004 09:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration