THE CODE :
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

void ShowStatus( int stat )
{
  if (WIFEXITED(stat))
    fprintf(stderr, "Normal termination: Exit status %d\n", WEXITSTATUS(stat) );
  else if (WIFSIGNALED(stat))
    fprintf( stderr, "Abnoral termination: Signal number %d\n", WTERMSIG(stat) );
  else
    fprintf(stderr,  "Unknown problem detected\n" );
}

int main(int argc, int **argv)
{
  pid_t retFork;
  int status;
  int up = 200;
  int down = 0;

   retFork= fork();  /*Create first child process*/
   switch (retFork){
   case -1:
     perror( "fork error" );
     exit (1);
   case 0:         /* Child process */
     exit( 1 );    /* Terminate normally */
   default:        /* Parent process */
    if (wait( &status ) != retFork){  /* wait for child */
      perror( "wait error" );
    }
    ShowStatus ( status );
  }



   retFork = fork();  /*Create second child process*/
   switch (retFork){
   case -1:
     perror( "fork error" );
     exit (1);
   case 0:         /* Child process */
     abort();    /* Generate SIGABRT */
     exit( 2 );     /*Terminate abnormally*/
   default:        /* Parent process */
    if (wait( &status ) != retFork ){  /* wait for child */
      perror( "wait error" );
    }
    ShowStatus ( status );
  }


   retFork = fork();  /*Create third child process*/
   switch (retFork){
   case -1:
     perror( "fork error" );
     exit (1);
   case 0:         /* Child process */
     up = up / down;    /* Generate SIGFPE (i.e., division by zero)*/
     exit(2);     /*Terminate abnormally*/
   default:        /* Parent process */
    if (wait( &status ) != retFork ){  /* wait for child */
      perror( "wait error" );
    }
    ShowStatus (status);
  }
   retFork = fork();  /*Create fourth child process*/
switch (retFork){
   case -1:
     perror( "fork error" );
     exit (1);
   case 0:         /* Child process */
     up = up / down;    /* Generate SIGFPE (i.e., division by zero)*/
     exit(2);     /*Terminate abnormally*/
   default:        /* Parent process */
    if (wait( &status ) != retFork ){  /* wait for child */
      perror( "wait error" );
    }
    ShowStatus (status);
  }
  return 0;
}

I have been given this code and told to:

i. Modify the createwaitprocess.c program to create a fourth child process which terminates due to a segmentation fault. Does the addition of the fourth process change the output produced from the first three processes? Explain.

So i added in a fourth child process but then i got stuck!!! Does anyone know wat a segmentation fault is?? Or how I am suppose to cause one in this program?

thnx