I've written a kernel module that provides a userspace interface to utrace. Among other things, it provides a blocking API call that returns when any of the enabled utrace report_* events of an attached process occur. This includes notification of process exit, death, and reap, and other things.
Since the mechanism is implemented as a module, it can attach to any process (except, I guess, init). One problem with this, however, is that it would be dangerous to give arbitrary processes utrace-level control over processes they don't own--I'm planning to put in some sort of permissions mechanism, but it's not in place yet. My code works, but it's no better than alpha- or early beta-level at the moment, and it's in the middle of an extensive API rewrite at the moment. But you're welcome to look at it if you think it will do you any good. I should have a fairly complete API spec done in a few days, and something of a HOWTO use it shortly after that. Stephane Eranian wrote: > Hello, > > I am looking for a kernel mechanism whereby a user process > could receive a notification, via a signal or blocking syscall > whenever another thread or process terminates. I am interested > in such a mechanism in a situation where the terminating thread > or process is NOT a descendant of the notifiee. Otherwise, I could > simply use SIGCHLD. > > Today, the solution is to ptrace that thread until it dies. But this > is overkill as we have to deal with signal forwarding and such. > > I am wondering: > - does utrace offer this kind of notification directly? > - if not, can this be built on top? > > > I am interested in this in the context of perfmon. You can attach > to another process to monitor it for a while or until it dies. It > is nice to avoid maintaining the monitored thread under ptrace during > the session. Today, perfmon uses its own notification mechanism via > a message queue to forward the information to use monitoring tool. > I'd rather use a standard kernel mechanism rather than this. > > Thanks. > > -- Chris Moller Java: the blunt scissors of programming languages. -- Dave Thomas
signature.asc
Description: OpenPGP digital signature