I Got it ..... it were fork the parent every time where it should fork the child.......Here the right coad ......
Code:
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
int N;
pid_t pid,child_pid;
int cont;
if (argc !=2)
{
printf("Wrong number of command-line parameters!\n");
return 1;
}
N = atoi (argv[1]);
printf("Creating process sequence of length %d.\n", N);
printf("%d begins the sequence.\n",getpid());
child_pid= fork();
for (cont =0 ; cont<N-1; cont++)
{
pid=getpid();
if ( child_pid==0)
{
printf("%dis child of %d.\n", getpid(),getppid());
child_pid=fork();
}
wait();
}
}