Let’s say we have the following:
pid_t pid;
pid = fork();
if(pid == 0) {
if(fork()) printf("A");
else printf("B");
printf("C");
}
else {
if(!fork()) printf("A");
else if (fork()) printf("B");
else printf("C");
}
How many A’s, B’s and C’s are going to be printed?
I’m a little bit confused with how fork() works inside “if” and whether I’m in parent or child process.
New contributor