Do I understand correctly that 2 processes are created in the code below? Since one fork () call creates one thread. There are two such calls in the code, therefore, the process is created 2?
There are actually 3 processes (4 if you count the parent). The parent does indeed fork twice, however the first child will also call fork. So you end up with a process tree like:
Also, just as a side note, forking used to be a threading method, but these days (to the best of my knowledge) its not a commonly used model for threading anymore.