i tried with the waitpid() function, it takes three argument, while i implement a below code , i had a some mistakes, instead of waitpid() function i use the wait() function with the three argument. it work properly i don't how its working. Any one can explain it??
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
main()
{
pid_t pid;
int p;
if((pid=fork())==0){
printf("Child present\n");
sleep(2);
printf("Child terminated\n");
_exit(0);
}
wait(pid,&p,0);
printf("parent terminated\n");
return 0;
}
But the syntax for the wait function is
pid_t wait(int *status);