Re: Using getpid() often, another way? [was Re: clone() <-> getpid()bug in 2.6?]

From: Linus Torvalds
Date: Sat Jun 12 2004 - 08:49:43 EST




On Sat, 12 Jun 2004, Dominik Straßer wrote:
>
> I am facing the following problem:
> I want to sum up the time spent in the main thread + all threads that
> ever existed.
> getrusage dosn't work (and didn't do so in pre-NPTL-times) as the time
> spent in threads is not taken into account.

Hmm.. That's likely a bug. It definitely should work, but I guess the
self-reaping ends up meaning that the time never gets percolated to the
parent any more.

Ingo, any comments/ideas?

> To work around this problem I created a map pid->time used which used
> getpid in the pre-NPTL-time and looked up the time in /proc/<pid>. As
> this doesn't work with NPTL, changed it to use the gettid syscall as I
> didn't find a saner way.

Changing it to gettid sounds like the right thing to do, but I also think
that you shouldn't _need_ to do things like this.

Linus
-
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/