LinuxQuestions.org
Help answer threads with 0 replies.
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 03-21-2004, 12:12 PM   #1
exedx
LQ Newbie
 
Registered: Mar 2004
Location: Warsaw Poland
Distribution: Fedora
Posts: 3

Rep: Reputation: 0
Unhappy sending signal to thread waiting on pselect


I am trying to implement the following scenario in the multithread application.

// main function of the application prepares global setting ....
// block reception of SIGCONT signal using sigsetmask call
sigset_t sigmask,oldmask;
sigemtyset(&sigmask);
sigaddset(&sigmask,SIGCONT);
sigprocmask(SIG_BLOCK,&sigmask,&oldmask);
// set global service for SIGCONT
signal(SIGCONT,sighndlr)
// ...
// s-thread waits on pselect on events on file descriptor sets enabling reception of SIGCONT
rc=pselect(max,&rfds,&wfds,&exfds,NULL,&oldmask);
// ... and in the mean time
// w-thread sends the SIGCONT to the s-thread informing that status of fdsets have changed
pthread_kill( s_thread_id, SIGCONT );

The above scenario I have tried with glibc 2.3.2 on Fedora with nptl library. The result is always the same. The application process disapear from the system.

What I am doing wrong?
Has anybody an idea how to wakeup the thread waiting on the (p)select system call using signals?
 
Old 03-21-2004, 02:26 PM   #2
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
the whole point of select is to find out if the FD SETS HAVE CHANGED, why would someone need to signal that? what does your sig handler look like? im guessin the signal is killing the process
 
Old 03-21-2004, 02:46 PM   #3
exedx
LQ Newbie
 
Registered: Mar 2004
Location: Warsaw Poland
Distribution: Fedora
Posts: 3

Original Poster
Rep: Reputation: 0
The reason is simply.
other thread returns the connection to the pool (e.g. when accepting new connection arrived) on which select waits on read events.

Edward
 
Old 03-21-2004, 04:35 PM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
what about the sig handler? can u verify the signal is being caught? any other info u can provide? do some tests..
 
Old 03-21-2004, 11:48 PM   #5
exedx
LQ Newbie
 
Registered: Mar 2004
Location: Warsaw Poland
Distribution: Fedora
Posts: 3

Original Poster
Rep: Reputation: 0
I have found workaround. The first thread is informed about fd set changes via socketpair on which select is also spanned.
Thanks,
Edward
 
  


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
how to send a signal to a thread stephenwalter Programming 2 10-17-2005 01:07 AM
Sending signal from one host to other zaheer031 Linux - Networking 1 11-04-2004 12:31 PM
Main thread sending notification to child thread rajesh_b Programming 1 09-22-2004 09:15 AM
Sending a signal to a process (Help me) rajesh_b Programming 2 09-17-2004 01:30 AM
Has anyone can give an example about using signal in thread? xhhuango Programming 2 09-15-2004 08:10 PM

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

All times are GMT -5. The time now is 12:46 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