/* a sample program that illustate the fuction times(). */
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/times.h>

int main() {
    int pid;
    int stat;
    struct tms buffer; 

    pid = fork();
    if(pid == 0)
    {
      printf(" This is child process, please wait\n");
      sleep(5);
    }
    else
    {
      wait(&stat);  /* wait the child process exit */
      times(&buffer);
      printf(" The child process exit\n");
      printf(" user time %d seconds\n",buffer.tms_utime);
      printf(" system time %d seconds\n",buffer.tms_stime);
      printf(" child process time %d seconds\n",buffer.tms_cutime);
      printf(" child system time %d seconds\n",buffer.tms_cstime); 
    }
}
