Re: signalfd API issues (was Re: [PATCH/RFC] signal races/bugs,losing TIF_SIGPENDING and other woes)

From: Benjamin Herrenschmidt
Date: Tue Jun 05 2007 - 23:52:37 EST


> That'd be a limitation. Like you can choose to not handle SEGV, you can
> choose to have a signalfd listening to it. Of course, not with the
> intention to *handle* the signal, but with a notification intent.

Hrm.. either you handle it or you are dead ... I fail to see how
signalfd can sneak in to catch it just at the right time...

> > I'm actually thinking we shoud -also- only handle shared signals in
> > dequeue_signal() when called from a different task.
>
> Why do you want to impose this? signalfd is a "sniffer", and the user
> controls what it can dequeue/sniff or what not. I don't see a reason of
> imposing such limits, unless there're clear technical issues.

Well, a synchronous signal such a SIGSEGV, SIGILL or SIGFPE generally
means that execution cannot continue unless the signal handler does
something about it...

I think you are opening a whole can of worms here.

> > Well.. you certainly need to instanciate a signalfd for every thread in
> > the process if you want to get shared signals for sure.
>
> Why? Or better, what do you mean for "instanciate"?

Well, because the kernel makes the decision of which thread to target
the signal for a shared signal at emission time (though it -can- be
caught by another thread).

/me reads more code to be sure..

Oh well, a read from signalfd created on one thread -will- catch any
shared signal that was already pending, whatever thread the kernel
decided to target it at, it seems (that is, whatever thread actually got
TIF_SIGPENDING set), but will only catch private signals for _that_
thread (and I still think catching private signals is a wrong thing).

However, I'm not sure about the wakeup condition. signalfd_deliver will
wakeup anybody in the signalfd_list, which is -not- whoever is blocked
in signalfd_read() unless I'm missing something.

For your scheme to work, signalfd_read() you probably need to keep a
separate list of people to be nofified of signals and add current to it
from signalfd_list().

Ben.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/