What is the purpose of fork()?

前端 未结 15 1260
悲哀的现实
悲哀的现实 2020-12-12 11:11

In many programs and man pages of Linux, I have seen code using fork(). Why do we need to use fork() and what is its purpose?

15条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 11:25

    fork() will create a new child process identical to the parent. So everything you run in the code after that will be run by both processes — very useful if you have for instance a server, and you want to handle multiple requests.

提交回复
热议问题