azhar baloch
azhar baloch

Reputation: 548

Why we create new processes using fork() or exec() system calls?

As we are taught in the class that new processes are created using fork() or exec() system calls.

Suppose we created a child process using fork(), what is the purpose of this newly created process? why we created that process?

I am asking about the applications where we have to create a new process.

Upvotes: 0

Views: 280

Answers (1)

Neil Ashford
Neil Ashford

Reputation: 21

A few example uses of creating new processes:

  • In the shell environment, each command you run (like ls) is its own binary file. The main shell program will fork() and then execute the relevant utility.
  • Web servers such as the Apache httpd server will create a new process using fork() to handle separate requests.
  • Some web browsers, like Chrome, create new processes for each tab that's open, in order to take advantage of the isolation between separate processes to improve security.
  • Desktop environments will fork and execute new processes each time you open an application through the GUI menu (such as the start menu in windows, or the dock in MacOS)
  • Build systems such as make fork and execute compilers as separate processes when building your code.

There are many others, but these are some examples of when you might need to use multiple processes in a program.

Upvotes: 0

Related Questions