[comp.unix.aux] getrusage command

zhengbin@HP-UX.yorku.ca (zhengbin wang) (05/09/91)

Hi, I am writing a short program as follows to test the usage of the
command getrusage, but the result is puzzling.  Can anybody help me with
it?   Thanks in advance.

Zhengbin@clid.yorku.ca

This is this result I got by running the compiled program.
===================
a.out
User time is 0 
signal received1 
message received0 
User time is 0 
User time is 0 
==================

#include <sys/types.h>
#include <sys/times.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <stdio.h>

main ()
{
	struct rusage pt_rusage;
	register int i,j;

	system("sleep 3\n");
	wait();
	getrusage(-1, &pt_rusage);
	fprintf(stderr,"User time is %d \n",pt_rusage.ru_stime.tv_sec);
	system("sleep 3\n");
	for ( i = 3; i <= 120; i ++ )
	  j=2;
	getrusage(RUSAGE_SELF, pt_rusage.ru_nsignals);
	fprintf(stderr,"signal received%d \n", pt_rusage.ru_nsignals);
	fprintf(stderr,"message received%d \n", pt_rusage.ru_msgrcv);
	fprintf(stderr,"User time is %d \n",pt_rusage.ru_stime.tv_sec);
	fprintf(stderr,"User time is %d \n",pt_rusage.ru_stime.tv_sec);

}