Mailinglist Archive: opensuse-programming (18 mails)

< Previous Next >
Re: [opensuse-programming] signal handling in bad threaded libraries
  • From: Per Jessen <per@xxxxxxxxxxxx>
  • Date: Wed, 06 Apr 2011 10:11:13 +0200
  • Message-id: <inh771$5f5$2@saturn.local.net>
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@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-programming+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups