Why is it possible that the if and else statements are executed on single run?

前端 未结 1 394
时光取名叫无心
时光取名叫无心 2021-01-27 04:43

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 proces

1条回答
  •  生来不讨喜
    2021-01-27 05:04

    Fork is used to create a new process. In the old process it returns the new process's pid and in the new process it returns 0. Each line of the output was printed by a different process.

    http://linux.die.net/man/2/fork

    To help you understand: From the moment you call fork() one more process is executing the program you wrote. To let you make these two processes do different things, fork() returns different values in the original process and in the duplicate. As I wrote, the original process receives pid of the new process, which is very useful for further communication between the two processes.

    0 讨论(0)
提交回复
热议问题