ps -S not working because kinfo_proc.kp_cru is not filled

Jan Lentfer Jan.Lentfer at
Wed Dec 16 01:53:05 PST 2009

when trying to improve top I was looking into ps's output when using option -S and found with the help of alexh that the numbers reported back or not what is described in man page:

-S : Change the way the process time is calculated by summing all exited children to their parent process

This seems due to the fact that for summing up childrens cpu time kinfo_proc.kp_cru is used in ps/print.c :

    443 	if (sumrusage) {
    444 		secs += KI_PROC(k, cru).ru_utime.tv_sec +
    445 			KI_PROC(k, cru).ru_stime.tv_sec;
    446 		psecs += KI_PROC(k, cru).ru_utime.tv_usec +
    447 			KI_PROC(k, cru).ru_stime.tv_usec;
    448 	}

scanning through DF sources in gives me the impression that kinfo_proc.kp_cru is not filled anywhere.

Other BSDs use similar approach for ps -S (fbsd: ki_childtime, obsd: p_uctime_sec), but these contain actual data (fbsd: kern_proc.c,obsd: kvm_proc.c).

So the question is, is this a ps bug and we should remove option -S (or add note that this doesn't work on DF) or should we actually will kp_cru with meaningful data?

Preisknaller: WEB.DE DSL Flatrate für nur 16,99 Euro/mtl.!

More information about the Bugs mailing list