getrusage command

zhengbin wang zhengbin at HP-UX.yorku.ca
Thu May 9 09:48:58 AEST 1991


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 at 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);

}



More information about the Comp.unix.aux mailing list