All pastes #931383 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-03-07 03:29 UTC
rendered paste body
#include <stdio.h>
#include <sys/types.h>

main()
{
 
 int childid;
 int parentid = getppid();
 
 childid = fork();
 
    if (childid == 0) /* this is the parent process */
    {
       printf("Created a child process\n");
    }
    else    /* this is the child process */
    {
      //The child program immediately goes into an infinite loop
      execl ("./child", "red", "white", "blue",  NULL);
    }
    //Why is this thing skipped? Shouldn't it wait indefinately 
    //since the child is in an infinite loop?
    waitpid(parentid);
    printf("How did I get here?\n");
    
}