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 {
PayPal Gateway not configured
PayPal Gateway not configured