Re: Killing clones

mjr@iki.fi
Thu, 14 Aug 1997 06:21:37 +0300 (EET DST)


On 13 Aug, Linus Torvalds wrote:
> Encoding the thread ID in the high bits was one of the ideas from the very
> beginning. That's what CLONE_PID is there for: the _intent_ was that
> CLONE_PID would change only the high bits, and then you could do a global
> kill (anything with the high bits zero would send a signal to _all_
> threads that shared the same low bits).

Hmm. Sounds otherwise good, but I think POSIX threads require that
signals be sent to exactly one thread, and it should be one whose
sigmask permits it. Could this be feasibly emulated in user space?
Or how about CLONE_SIG (or similiar)? If signals would be set not to be
distributed to all threads, signals to processes with high bits zero
would be sent to the first thread (therefore _not_ giving the first
thread special treatment with respect to signals), or even better; some
thread with the same low bits and a sigmask to allow the signal (though
this latter part could be emulated in user space; YMMV on where it
should really be).

(Actually, I sent a suggestion to Xavier Leroy to emulate the POSIX
behaviour by having dummy signal handlers in each thread to intercept
incoming signals and send them to other threads if the one that
originally got them didn't want to handle it. Dirty, but at least it
should work. Whether it's worth it or not depends on when better kernel
support arrives...)

> My personal favourite for /proc would be that any CLONE_PID threads would
> show up _inside_ the original parent (that's kind of the basic idea with

Seems the most reasonable option to me, too.

-- 
Mikko Rauhala, reservin sivari - mjr@iki.fi - http://www.iki.fi/mjr/