Course Solutions Uncategorized (Solved) : Modify Program Create 2 Children Output Following Parent Pid Xxx Child Pid Xxx Child Pid X Q26323541 . . . .

(Solved) : Modify Program Create 2 Children Output Following Parent Pid Xxx Child Pid Xxx Child Pid X Q26323541 . . . .

 

Now modify the programto create 2 children. The output should be the following:

– I am the parent withpid: XXX 

– I am the child withpid: XXX 

– I am the child withpid: XXX 

– I am the parent withpid: XXX and finishing after waiting for my kids.

TheCode

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

int
main(int argc, char *argv[])
{
    printf(“hello world (pid:%d)n”, (int)getpid());
    int rc = fork();
    if (rc < 0) {
        // fork failed;exit
        fprintf(stderr, “forkfailedn”);
        exit(1);
    } else if (rc == 0) {
        // child (newprocess)
        printf(“hello, I amchild (pid:%d)n”, (int) get$
        sleep(1);
    } else {
       

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post