Sobes.tech
Junior — Middle

Explain what a fork process is in the Linux operating system and how it works

sobes.tech AI

Answer from AI

In Linux, the fork process is a system call that creates a new process by copying the current (parent) process. The new process is called the child and initially is an exact copy of the parent, including memory, variables, and execution state.

How fork works:

  • The parent calls fork()
  • The operating system creates a new process with a new PID
  • The child process receives a copy of the parent's address space (modern systems use copy-on-write for optimization)
  • After fork(), both processes continue execution from the point of the fork() call, but fork() returns 0 in the child process and the child's PID in the parent

This allows creating parallel processes to perform different tasks.