Trying to learn about processes and such in UNIX.
I wrote this little thing to help me try to understand.
Can someone help me with the correct way to access the data from the rusage struct. I would like to be able to generate a line which shows the system, user and real time used by the process, but am confused on how to get data.
void child( char *command, char *arg );
char *arg, *tm;
char *command = "ls";
struct rusage *data;
int pid, w_child;
pid = fork();
if( pid == 0 )
child( command, arg);
else if( pid > 0 )
w_child = wait3(NULL, 0, data);
/* HOW do i get access to statistics from wait3()
tm = ctime((data.ru_utime)->tv_sec);
printf( "%s\n", tm);
printf( "END: you should see 'ls -l'.\n" );
printf( "The parent pid is: %d\n", getpid() );
printf( "The child pid was: %d\n", w_child );
void child( char *command, char *arg )
arg = "";
arg = "-l";
arg = 0;
execvp( command, arg );
Any pointers (sorry, bad joke) would be appreciated.