I have read about the operation of the call fork () and so far I have understood that it makes a copy of the process that is running and through a fork it is possible to know if we are in the process father or son as in the next example.
Now that I understand how this function works, I am trying to make a program that creates two children processes in the following way
According to my logic, the output of this program should be: "I'm in the child 1" "I'm in the child 2" However, the program does not always print that on the screen. Sometimes it prints only "I'm in the child 1" And I would like to know why this happens? If, according to me, the parent process creates a child process and in the part of the where the father code should go, I create another process (child 2) and this should print its message without problems. Can anyone help me understand why this happens, please?