Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting running time of child

0 views
Skip to first unread message

Koffie Yahoo

unread,
Nov 19, 2009, 5:46:57 AM11/19/09
to freebsd...@freebsd.org
Dear all,

I've looked but not found (and I hope I'm in the right group here): Is
there a way to get the user time and system time of a /running/ child
from its parent (without having to mount procfs)? As far as I was able
to tell, I can get the total of user and system time using
kvm_getprocs, but it doesn't seem possible to get both values
separately.

Regards,

Jay
_______________________________________________
freebsd...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hacke...@freebsd.org"

Dag-Erling Smørgrav

unread,
Nov 19, 2009, 8:27:51 AM11/19/09
to Koffie Yahoo, freebsd...@freebsd.org
Koffie Yahoo <koffi...@gmail.com> writes:
> I've looked but not found (and I hope I'm in the right group here): Is
> there a way to get the user time and system time of a /running/ child
> from its parent (without having to mount procfs)?

If you have only one child, there's getrusage(2).

DES
--
Dag-Erling Smørgrav - d...@des.no

Koffie Yahoo

unread,
Nov 19, 2009, 9:52:56 AM11/19/09
to freebsd...@freebsd.org
>> I've looked but not found (and I hope I'm in the right group here): Is
>> there a way to get the user time and system time of a /running/ child
>> from its parent (without having to mount procfs)?
>
> If you have only one child, there's getrusage(2).

Unfortunately, that only works for children that have terminated, not
for active children. I'm interested in active children.

Jay

Dag-Erling Smørgrav

unread,
Nov 19, 2009, 10:08:52 AM11/19/09
to Koffie Yahoo, freebsd...@freebsd.org
Koffie Yahoo <koffi...@gmail.com> writes:
> Unfortunately, that only works for children that have terminated, not
> for active children. I'm interested in active children.

Hmm, we could probably add a ptrace(2) operation, but ptrace(2) is
inherently evil.

DES
--
Dag-Erling Smørgrav - d...@des.no

Boris Kochergin

unread,
Nov 19, 2009, 10:13:31 AM11/19/09
to Koffie Yahoo, freebsd...@freebsd.org
It's not as portable as getrusage(2), but you could probably get the
information you want using libkvm's kvm_getprocs(3) function. The
information available is defined in the kinfo_proc structure in
/usr/include/sys/user.h.

-Boris

Dag-Erling Smørgrav

unread,
Nov 19, 2009, 10:21:43 AM11/19/09
to Boris Kochergin, freebsd...@freebsd.org, Koffie Yahoo
Boris Kochergin <sp...@acm.poly.edu> writes:
> It's not as portable as getrusage(2), but you could probably get the
> information you want using libkvm's kvm_getprocs(3) function. The
> information available is defined in the kinfo_proc structure in
> /usr/include/sys/user.h.

Read the original post.

DES
--
Dag-Erling Smørgrav - d...@des.no

Koffie Yahoo

unread,
Nov 19, 2009, 10:24:06 AM11/19/09
to freebsd...@freebsd.org
> It's not as portable as getrusage(2), but you could probably get the
> information you want using libkvm's kvm_getprocs(3) function. The
> information available is defined in the kinfo_proc structure in
> /usr/include/sys/user.h.

Unfortunately, as far as I can see the kinfo_proc structure only contains
the sum of user time and system time and not the two values separately,
or have I missed something?

Koffie Yahoo

unread,
Nov 19, 2009, 3:16:24 PM11/19/09
to Dan Nelson, freebsd...@freebsd.org
That's it! Thanks! Problem solved :-)

Jay

On Thu, Nov 19, 2009 at 5:34 PM, Dan Nelson <dne...@allantgroup.com> wrote:
> In the last episode (Nov 19), Koffie Yahoo said:
>> > It's not as portable as getrusage(2), but you could probably get the
>> > information you want using libkvm's kvm_getprocs(3) function. The
>> > information available is defined in the kinfo_proc structure in
>> > /usr/include/sys/user.h.
>>
>> Unfortunately, as far as I can see the kinfo_proc structure only contains
>> the sum of user time and system time and not the two values separately,
>> or have I missed something?
>

> Take a look at the the ki_rusage struct inside kinfo_proc.
>
> --
> � � � �Dan Nelson
> � � � �dne...@allantgroup.com

0 new messages