#include <stdio.h> 
#include <sys/wait.h> /* contains prototype for wait */ 
int main(void) 
{ 
int pid; 
int status; 
printf("Hello World!\n"); 
pid = fork( ); 
if(pid == -1) /* check for error in fork */ 
{ 
perror("bad fork"); 
exit(1); 
} 
if (pid == 0) { 
printf("I am the child process.\n");
printf("My Process ID (PID) is: %d\n", getpid());
printf("My Parent's PID is: %d\n", getppid()); }
else 
{ 
wait(&status); /* parent waits for child to finish */ 
printf("I am the parent process.\n"); 
printf("My PID is: %d\n", getpid());
} }