Re: Fix signalfd interaction with thread-private signals

Nicholas Miell
2007-06-22T23:52:24Z

On Sat, 2007-06-23 at 09:19 +1000, Benjamin Herrenschmidt wrote:
> On Sat, 2007-06-23 at 09:16 +1000, Benjamin Herrenschmidt wrote:
> > On Fri, 2007-06-22 at 15:47 -0700, Linus Torvalds wrote:
> > > Quite frankly, it strikes me that if we want to do this, then we shouldn't
> > > save the _process_ information at all, we should save the "sighand"
> > > instead.
> > >
> > > So either we save the process info, or we save the sighand, but saving the
> > > "group_leader" seems totally bogus. Especially as the group leader can
> > > change (by execve()).
> > >
> > > One thing that strikes me as I look at that function is that the whole
> > > signalfd thing doesn't seem to do any reference counting. Ie it looks
> > > totally buggy wrt passing the resulting fd off to somebody else, and then
> > > exiting in the original process.
> > >
> > > What did I miss?
> >
> > Probably nothing... doesn't look good. What are the lifetime rules of a
> > struct sighand tho ?
>
> Ah got it, signalfd_detach() in include/linux/signalfd.h from
> exit_signal plus some rcu bits in signalfd lock/unlock.

You could just get rid of the process/sighand/whatever reference
entirely and just make reads on a signalfd always dequeue signals for
the current thread.

You'd lose the ability to pass signalfds around to other processes, but
I'm not convinced that is even useful. (But I'm sure somebody smarter
than me has a valid use case and would love to share :-)

--
Nicholas Miell <nmiell@comcast.net>