hi , i need help please, i have the following code but im not sure about how many childs are created and if the parent executes the first if statement : if ((i & 1) && fork() == 0) , or not , since im confused about the term (i & 1) && fork() == 0.
if someone can draw the parent - child process tree and tell me please how that if statement is to be understood i would be very thankfull , i didnot add sleep() so you can check it as you want. please help.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
int i = 2;
for (i=2; i<=4; i++){
printf("Hello %d\n", i);
if ((i & 1) && fork() == 0){
printf("OS %d\n", i);
fork();
if (fork() > 0)
exit(1);
printf("Students\n");
}
else
printf("World\n");
}
return 0;
}
many thanks in advance