Process forking in PHP on Linux

Command Line with PHP

_ Introduced with PHP 4.3 (2002-12-27)
_ PHP packed with very useful functions: exec, shell_exec, passthru
_ PEAR package Console_CommandLine to easily handle arguments and options
_ You can do system administration and release management with a language you already know
_ Bad: if you run very long and complex processes (i.e. Parsing XML files into database), you can experience memory leaks
_ Bad: PHP is mainly for running short scripts to serve web pages so core developers focus time on that
_ Those issues are going to be addressed soon (something already done as of 5.3)

MultiProcess programming with PHP
_ ps auxf to see the parent/child process tree
_ There are basically 2 methods:
__ pcntl_fork()
__ exec

  • http://www.electrictoolbox.com/article/php/process-forking/
  • http://www.rooftopsolutions.nl/article/213
  • http://dev.mysql.com/doc/refman/5.1/en/gone-away.html (search for fork)
  • See the PHP ProcessControl class
This entry was posted in PHP, System Administration. Bookmark the permalink.

Leave a Reply