Fork - When a unix process creates a copy of itself.

Fork is an operation in Unix whereby a process creates a copy of itself. It is usually a system call, implemented in the kernel. Fork is the primary (and historically, only) method of process creation on Unix-like operating systems.

It’s a common technique used in Unix system programming.

Daemonizing a process involves the following steps:

  • Fork off the parent process.

  • Change file mode mask (umask)

  • Open any logs for writing

  • Create a unique Session ID (SID)

  • Change the current working directory to a safe place.

  • Close standard file descriptors.

  • Enter the actual daemon code.

For more information on daemons this guide is helpful.

See Fork: https://en.wikipedia.org/wiki/Fork_(system_call)