Subject: kern/15327: getrusage(2) not reporting all statistics
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dbj@netbsd.org>
List: netbsd-bugs
Date: 01/21/2002 20:25:38
>Number: 15327
>Category: kern
>Synopsis: getrusage(2) not reporting all statistics
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jan 21 17:32:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Darrin B. Jewell
>Release: NetBSD 1.5ZA 20020116T1504Z
>Organization:
>Environment:
System: NetBSD quiteria 1.5ZA NetBSD 1.5ZA (QUITERIA) #1: Thu Jan 17 23:58:17 EST 2002 dbj@quiteria:/usr/src/sys/arch/macppc/compile/QUITERIA macppc
Architecture: powerpc
Machine: macppc
>Description:
getrusage does not appear to get valid values for some fields,
for example, the test program included below retreived these
values for itself:
r = 0
ru_utime.tv_sec = 0
ru_utime.tv_usec = 0
ru_stime.tv_sec = 0
ru_stime.tv_usec = 0
ru_maxrss = 0
ru_ixrss = 0
ru_idrss = 0
ru_isrss = 0
ru_minflt = 67
ru_majflt = 0
ru_nswap = 0
ru_inblock = 1
ru_oublock = 1
ru_msgsnd = 0
ru_msgrcv = 0
ru_nsignals = 0
ru_nvcsw = 2
ru_nivcsw = 0
>How-To-Repeat:
#include <stdlib.h>
#include <stdio.h>
#include <sys/resource.h>
int
dump_rusage(FILE *f)
{
int r;
struct rusage ru;
memset(&ru,0xff,sizeof(ru));
r = getrusage(RUSAGE_SELF,&ru);
if (r == -1) {
perror("getrusage");
}
fprintf(f,"r = %d\n",r);
fprintf(f,"ru_utime.tv_sec = %ld\n",ru.ru_utime.tv_sec);
fprintf(f,"ru_utime.tv_usec = %ld\n",ru.ru_utime.tv_usec);
fprintf(f,"ru_stime.tv_sec = %ld\n",ru.ru_stime.tv_sec);
fprintf(f,"ru_stime.tv_usec = %ld\n",ru.ru_stime.tv_usec);
fprintf(f,"ru_maxrss = %ld\n",ru.ru_maxrss);
fprintf(f,"ru_ixrss = %ld\n",ru.ru_ixrss);
fprintf(f,"ru_idrss = %ld\n",ru.ru_idrss);
fprintf(f,"ru_isrss = %ld\n",ru.ru_isrss);
fprintf(f,"ru_minflt = %ld\n",ru.ru_minflt);
fprintf(f,"ru_majflt = %ld\n",ru.ru_majflt);
fprintf(f,"ru_nswap = %ld\n",ru.ru_nswap);
fprintf(f,"ru_inblock = %ld\n",ru.ru_inblock);
fprintf(f,"ru_oublock = %ld\n",ru.ru_oublock);
fprintf(f,"ru_msgsnd = %ld\n",ru.ru_msgsnd);
fprintf(f,"ru_msgrcv = %ld\n",ru.ru_msgrcv);
fprintf(f,"ru_nsignals = %ld\n",ru.ru_nsignals);
fprintf(f,"ru_nvcsw = %ld\n",ru.ru_nvcsw);
fprintf(f,"ru_nivcsw = %ld\n",ru.ru_nivcsw);
return r;
}
int
main(int argc, char *argv[])
{
int r;
r = dump_rusage(stdout);
if (r == -1) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: