[UPHPU] Forking A Script
Scott Hill
llihttocs at gmail.com
Mon Jul 23 13:19:54 MDT 2007
On 7/23/07, Orson Jones <orson.uphpu at bookstore.usu.edu> wrote:
>
> Looking around php.net I found this
>
> http://us2.php.net/manual/en/function.pcntl-fork.php
>
> You can do a standard fork() using php. Check it out.
>
> Orson
If you don't care about the child process after it is finished, you must do
a pcntl_signal(SIGCHLD,SIG_IGN); before the fork. This will make the parent
process ignore any signal sent back by a dying child. When the child
process sees that it's kill signal was either processed or ignored, it dies
quietly. This prevents what is known as zombie or orphan processes in *nix,
which is a dead child process that has been shunned by its parent. If you
want to track the process of the child process, leave out the pcntl_signal
and use pcntl_waitpid after the fork. This is a very, very common occurance
in the *nix world. For example, the apache server forks a child process for
every request on its socket(s). And I don't care what anyone says (about XP
or Vista), Windows still sucks when it comes to forking any kind of process.
My humble $.02.
--
Scott Hill
"May you solve interesting problems" - Author Unknown
"A fanatic is one who can't change his mind and won't change the subject." -
Sir Winston Churchill
More information about the UPHPU
mailing list