I am learning about socket programming and I know c-programming well.
For example, based on my c-programming knowledge, once something inside an else statement is processed, the code inside the corresponding if statement should not get executed. For instance,
int a = 1;
if(a == 1) process1 ;
else process2;
Based on the statement above, a equals to 1, so process1
should be executed and process2
will not be executed. I believe this is correct.
My question is illustrated with the following code:
int main(void){
pid_t pid;
int pp[2];
pipe(pp);
pid = fork();
if(pid == 0){
printf("Processed pid == 0\n");
}else{
printf("Processed pid != 0\n");
}
return 0;
}
I get the following output when I run this program:
Processed pid == 0
Processed pid != 0
My question is WHY is the result of both the if
and else
statement shown?