Consider this:
main()
{
int i = 1;
fork(); fork(); fork();
printf("%d ",i);
}
The output of the above code:
1 1 1 1 1 1 1 1
That is, at the end there are 8 (2 ^ 3) processes reaching the line printf(). Now consider the following code:
main()
{
int i = 1;
fork() && fork() || fork();
printf("%d ",i);
}
At first, I thought that the result would not change, because the results of comparisons using &&are ||not evaluated by a control operator such as ifor while. That is, they are discarded. However, the output of this code is:
1 1 1 1 1
Meaning: at the end there are 5 processes that reach the line printf().
My question is: what does this line do
fork() && fork()||fork();
, - . , &&, || if, while , , . , ; 1 0, .
, .