
/* process creation in unix          */
/* Examples using system call fork  */

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <time.h>
#include <sys/wait.h>


int main()
{
  int retVal;
 
  printf(" Just one process so far\n");
  printf(" Calling fork() system call\n");

  retVal = fork();  /* create new process*/
   if (retVal == 0)
     {sleep(5);
       printf(" I am the child \n");}
  else if (retVal > 0)
    { 
      
      printf(" I am the parent, child has pid  %d \n", retVal); sleep(10); }
  else
    printf(" Fork returned an error %d \n", retVal);
  return 0;
}
