News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Re-Cycled Air Blog:
PHP Dark Arts Daemonizing a Process
October 29, 2010 @ 11:02:36

On the Re-Cycled Air blog Jack Slingerland has posted another in his "Dark Arts" series looking at some of the lesser used PHP features. This time he focuses in on daemonizing a process by forking it off into the background.

One of the many things you don't often do with PHP (actually, I'm not sure you do this much with any language) is daemonize a process. A daemon is program that runs in the background (read more here). On Unix systems, processes are usually created by forking the init process and then manipulating the process to your liking. To create a daemon though, you need to get the init process to adopt your process. To do that, as soon as you fork the parent process, you kill the parent. Since you child process is parent-less, the init process generally adopts it. Once that happens, your process has been daemonized.

He uses the pcntl_fork function to spawn off the child process, detach it from a terminal window, create a ".pid" file so the system knows about it and then, of course, have the child script do something.

1 comment voice your opinion now!
daemon process child parent tutorial


blog comments powered by Disqus

Similar Posts

NetTuts.com: SOLID: Part 2 The Open/Closed Principle

PHPBuilder.com: Using XML, Part 5 - SOAP and WSDL

Stefan Mischook's Blog: PHP Sessions Video Tutorials - Part 2

PHPBuilder.com: Using SPL Iterators in PHP to Interact with Different Data Types

Zend: Roll Your Own Search Engine with Zend_Search_Lucene


Community Events





Don't see your event here?
Let us know!


unittest wordpress refactor series list framework opinion threedevsandamaybe developer language configure introduction install code interview testing community podcast release laravel

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework