[opensuse-programming] signal handling in bad threaded libraries

I am using a library that starts lots of threads. It is a proprietary lib and there is no choice as it talks to some company's fancy schmancy hardware. The problem I have is that, it seems (strace is great), this library does not set it up so the threads it creates will not receive signals. In my own much-better-behaved-if-I-do-say-so code, I use pthread_sigmask in the created thread to say that I do not want various signals. Since I see my SIGIO signal delivered to both my thread (really the original process not a thread) or any of the threads created in the library, I think this is what is happening. My question is: how can I turn off delivery of signals to threads I did not create? I basically need to try to do for the threads what they did not do themselves. Add to that: how can a process find out what threads there are? I would imagine that if signal fiddling is even possible, I may need to know this as well. Yours sincerely, Roger Oberholtzer OPQ Systems / Ramböll RST Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 roger.oberholtzer@ramboll.se ________________________________________ Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden www.rambollrst.se -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org

On Tue, 2011-04-05 at 16:29 +0200, Roger Oberholtzer wrote:
My question is: how can I turn off delivery of signals to threads I did not create? I basically need to try to do for the threads what they did not do themselves. Add to that: how can a process find out what threads there are? I would imagine that if signal fiddling is even possible, I may need to know this as well.
Clarification: my process did create the threads. It is just that they were started in a library. I do not have access to them. Or at least I have never tried to control threads created elsewhere. Yours sincerely, Roger Oberholtzer OPQ Systems / Ramböll RST Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 roger.oberholtzer@ramboll.se ________________________________________ Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden www.rambollrst.se -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org

On Tue, 2011-04-05 at 16:29 +0200, Roger Oberholtzer wrote:
I am using a library that starts lots of threads. It is a proprietary lib and there is no choice as it talks to some company's fancy schmancy hardware.
The problem I have is that, it seems (strace is great), this library does not set it up so the threads it creates will not receive signals. In my own much-better-behaved-if-I-do-say-so code, I use pthread_sigmask in the created thread to say that I do not want various signals. Since I see my SIGIO signal delivered to both my thread (really the original process not a thread) or any of the threads created in the library, I think this is what is happening.
My question is: how can I turn off delivery of signals to threads I did not create? I basically need to try to do for the threads what they did not do themselves. Add to that: how can a process find out what threads there are? I would imagine that if signal fiddling is even possible, I may need to know this as well.
(Sorry for posting again.) Instead of trying to figure a way to change a thread's signal settings, I have tried setting the process signal mask to block the signal I do not want the threads to see before the threads are created. After I 'think' the threads have been created, I then set it to how I want the parent process to have it. Still, at some point a thread gets my signal. In strace, I only see the main process fiddling with threads. It does not look to me like any thread is mucking about. Is it the case that a thread has to actively change it's signal preferences? A change in the parent thread - after the 'child' thread is created, should not effect the child thread's signals. Or do I have this all wrong? Yours sincerely, Roger Oberholtzer OPQ Systems / Ramböll RST Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 roger.oberholtzer@ramboll.se ________________________________________ Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden www.rambollrst.se -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org

Roger Oberholtzer wrote:
On Tue, 2011-04-05 at 16:29 +0200, Roger Oberholtzer wrote:
I am using a library that starts lots of threads. It is a proprietary lib and there is no choice as it talks to some company's fancy schmancy hardware.
The problem I have is that, it seems (strace is great), this library does not set it up so the threads it creates will not receive signals. In my own much-better-behaved-if-I-do-say-so code, I use pthread_sigmask in the created thread to say that I do not want various signals. Since I see my SIGIO signal delivered to both my thread (really the original process not a thread) or any of the threads created in the library, I think this is what is happening.
My question is: how can I turn off delivery of signals to threads I did not create? I basically need to try to do for the threads what they did not do themselves. Add to that: how can a process find out what threads there are? I would imagine that if signal fiddling is even possible, I may need to know this as well.
(Sorry for posting again.)
Instead of trying to figure a way to change a thread's signal settings, I have tried setting the process signal mask to block the signal I do not want the threads to see before the threads are created. After I 'think' the threads have been created, I then set it to how I want the parent process to have it.
Yes, that is how you control the signals for a thread.
Still, at some point a thread gets my signal. In strace, I only see the main process fiddling with threads. It does not look to me like any thread is mucking about.
Is it the case that a thread has to actively change it's signal preferences? A change in the parent thread - after the 'child' thread is created, should not effect the child thread's signals. Or do I have this all wrong?
A thread will inherit the signal mask from the parent at the time of creation. A later change in the parent should not affect the child. /Per Jessen, Zürich -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org

On Wed, 2011-04-06 at 10:11 +0200, Per Jessen wrote:
A thread will inherit the signal mask from the parent at the time of creation. A later change in the parent should not affect the child.
I have explored further and see that the mask was changed in some way in the main process before the threads were created, messing up what I thought was the mask. I have a couple of suspect libraries that may be sloppy with signal masks. So I need to see who fiddled where they should not have fiddled. But I see that I can make the threads in the proprietary library not receive signals they have no interest in receiving. Progress. Slow. But progress nonetheless. Yours sincerely, Roger Oberholtzer OPQ Systems / Ramböll RST Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 roger.oberholtzer@ramboll.se ________________________________________ Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden www.rambollrst.se -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
participants (2)
-
Per Jessen
-
Roger Oberholtzer