By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,985 Members | 1,712 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,985 IT Pros & Developers. It's quick & easy.

Help with PHP Process Control Functions

P: n/a
Hi,

I have written a script that basically sends an email (using sockets). I
want this script to be able to run multiple copies of itself so that it
doesn't have to wait for one mail sending to finish before starting on the
next. I understand that I need to use the PHP pcntl_ family of functions to
control the processes, but am not sure where to start. There aren't many
helpful articles on the internet about this topic! Any example code or help
would be greatly appreciated.

Thanks,
Colin.
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Wed, 3 Dec 2003 13:03:42 -0000, "Colin Davis"
<co***@ssinternet.co.uk> wrote:
Hi,

I have written a script that basically sends an email (using sockets). I
want this script to be able to run multiple copies of itself so that it
doesn't have to wait for one mail sending to finish before starting on the
next. I understand that I need to use the PHP pcntl_ family of functions to
control the processes, but am not sure where to start. There aren't many
helpful articles on the internet about this topic! Any example code or help
would be greatly appreciated.

Thanks,
Colin.


This sample has had a lot of code removed, but it may help
understanding how this works: PHP must be compiled with pcntl.

$pid = pcntl_fork();
if ($pid)
{
// we are the parent
sleep(1);
$pid1 = pcntl_fork();
if ($pid1)
{
sleep(1);
$pid2 = pcntl_fork();
if($pid2)
{
sleep(1);
$pid3 = pcntl_fork();
if($pid3)
{
sleep(1);
}
else
{
// we are in child
sleep(1);
# Do something here
}
}
else
{
// we are in child
sleep(1);
# Do something here
}
}
else
{
// we are in child
sleep(1);
# Do something here
}

}
else
{
// we are the child
sleep(1);
# Do something here
}

Jul 17 '05 #2

P: n/a
Hello,

On 12/03/2003 11:03 AM, Colin Davis wrote:
I have written a script that basically sends an email (using sockets). I
want this script to be able to run multiple copies of itself so that it
doesn't have to wait for one mail sending to finish before starting on the
next. I understand that I need to use the PHP pcntl_ family of functions to
control the processes, but am not sure where to start. There aren't many
helpful articles on the internet about this topic! Any example code or help
would be greatly appreciated.


You may want to try this PHP thread class:

http://www.phpclasses.org/threadclass
--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.