The next logical step in the development of our queue service is to allow the application to push itself into the background of a system and run detached from a terminal.
What is forking?
Forking is when you take one process, and clone it to create another with the same state as the original. When our application executes we will clone it, let the new copy take ownership of itself, and terminate the original. This leaves a background process or daemon running in the background still ready to process our queue.
PHP by default does not have the functions we need enabled. In order to enable them PHP will need to be compiled with the option –enable-pcntl. This will make the pcntl_* function set available to us.
Wanna fork?
Forking is a fairly simple process. The best time to fork is early on in the program, because when we do it literally everything about the application state gets copied over. This means file handles, database pointers, everything… and this usually causes problems. Fork before you open your files and databases, and you will find your life running much smoother.

