Running the code (with some debug added) shows me five processes, and nine stars, and I have a rational explanation of how that happens, which will follow shortly.
Each fork and printf is labelled for reference, and the Stars identify the process tree. I added a sleep so that none of the processes exits prematurely, because their children would all get reparented to PID 1.
I assume fork() never fails, so every fork returns twice, with two different values: the parent gets the child's PID, and the child gets a zero. I label the processes A to E in the narrative, but their actual pids appear in the debug. Process A is started by the shell, the other four processes are each started by a fork().
1:fork returns B in the parent A, which is (boolean) true. That satisfies the OR condition, so 2:fork is skipped and process A enters the inner clause.
1:fork returns zero in the child B, which is false. So the second part of the || needs to be evaluated.
2:fork returns C to child B (which is now also a parent), so the OR condition is true and B enters the inner clause.
2:fork returns zero to child C, so the OR condition is false, and process C skip the inner clause and goes direct to 5:.
3:fork is entered by two processes (directly by A, indirectly by B) and creates further processes D and E.
4:printf shows four processes from the inner clause: A, B, D, E.
5:printf shows all five processes, because C skipped the inner clause.
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main (int argc, char *argv[])
{
char *Star = "[*]";
if (/* 1: */ fork() || /* 2: */ fork()) {
/* 3: */ fork();
printf ("4: Pid %d Parent %d %s\n", getpid (), getppid (), Star);
}
printf ("5: Pid %d Parent %d %s\n", getpid (), getppid (), Star);
sleep (3); // Avoid children being reparented to Init.
return (0);
}
paul: ~/SandBox/Fraction $ ./Fork
4: Pid 15120 Parent 11318 [*]
5: Pid 15120 Parent 11318 [*]
4: Pid 15122 Parent 15120 [*]
5: Pid 15122 Parent 15120 [*]
4: Pid 15121 Parent 15120 [*]
5: Pid 15121 Parent 15120 [*]
4: Pid 15124 Parent 15121 [*]
5: Pid 15124 Parent 15121 [*]
5: Pid 15123 Parent 15121 [*]
paul: ~/SandBox/Fraction $