Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-20-2010, 11:25 AM
|
#1
|
|
LQ Newbie
Registered: Jul 2010
Posts: 4
Rep:
|
do threads in the process share the signal handler?
Hi
I am studying the Advanced Programming in the Unix Environment these days. When I come to the chapter of Threads and signals, I find it difficult for me to understand the statement that the signal disposition is shared by all threads in the process.
Dose it mean that threads in the same process share the signal handler or just the attributes that set by sigaction ?
I will appreciate your helping me.
|
|
|
|
08-21-2010, 08:10 PM
|
#2
|
|
Guru
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.4, Centos 5.9
Posts: 14,956
|
It's true that signals are sent to the (overall) process (pid); you can't send a signal to an individual thrd, so you need to be real careful and ideally minimize the amt of code in a sig handler routine.
Best to just set a flag for the normal code to deal with and leave it at that.
One exception I've used is to use SIGHUP to re-read the cfg file. Apache does the same.
Also, you might want to ask the mods to move this to the Programming forum (use the Report button)
|
|
|
|
08-22-2010, 07:57 AM
|
#3
|
|
LQ Newbie
Registered: Jul 2010
Posts: 4
Original Poster
Rep:
|
Quote:
Originally Posted by chrism01
It's true that signals are sent to the (overall) process (pid); you can't send a signal to an individual thrd, so you need to be real careful and ideally minimize the amt of code in a sig handler routine.
Best to just set a flag for the normal code to deal with and leave it at that.
One exception I've used is to use SIGHUP to re-read the cfg file. Apache does the same.
Also, you might want to ask the mods to move this to the Programming forum (use the Report button)
|
Thank for you reply.
From my understanding, If a nonblocking signal is sent to a process,every thread in the processs will do the same thing.Because the threads share the the signal handler.
Is that right?
I new here.This my first post in this forum.I do not know how to move my post to programming.
|
|
|
|
08-22-2010, 12:06 PM
|
#4
|
|
Member
Registered: Jan 2009
Location: /dev/ph
Distribution: Fedora, Ubuntu, Redhat, Centos
Posts: 280
Rep:
|
Quote:
Originally Posted by chrism01 View Post
It's true that signals are sent to the (overall) process (pid); you can't send a signal to an individual thrd
|
Humm. You can send a signal to an individual thread. The POSIX API is pthread_kill
|
|
|
|
08-22-2010, 12:13 PM
|
#5
|
|
Senior Member
Registered: Sep 2003
Posts: 3,171
Rep: 
|
Quote:
Originally Posted by feiyinzilgd
Thank for you reply.
From my understanding, If a nonblocking signal is sent to a process,every thread in the processs will do the same thing.Because the threads share the the signal handler.
Is that right?
I new here.This my first post in this forum.I do not know how to move my post to programming.
|
The threads will do what they are told to do. The signal handler will dictate what the threads are told to do.
|
|
|
|
08-23-2010, 04:15 AM
|
#6
|
|
Guru
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.4, Centos 5.9
Posts: 14,956
|
@fmurphy: indeed, but from that same page:
Quote:
|
Note that pthread_kill() only causes the signal to be handled in the context of the given thread; the signal action (termination or stopping) affects the process as a whole.
|
What I meant to say was that a signal sent from outside the process eg
kill -SIGHUP <pid of process>
cannot be specified to target a given thread; it's delivered to the process as a whole and the actual thread that will first respond is undefined.
|
|
|
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:22 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|