/* * getrusage example */ #include #ifndef RUSAGE_SELF #include #endif #ifdef PIOCUSAGE int fd; char proc[SOMETHING]; prusage_t prusage; sprintf(proc,"/proc/%d", getpid()); if ((fd = open(proc,O_RDONLY)) == -1) { perror("open"); .... } if (ioctl(fd, PIOCUSAGE, &prusage) == -1) { perror("ioctl"); ... } .... #else /* Again, assume BSD */ if (getrusage(RUSAGE_SELF, &rusage) == -1) { perror("getrusage"); .... } .... #endif /* PIOCUSAGE */