473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with PHP Process Control Functions

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
2 2227
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
6
by: Jamal | last post by:
I am working on binary files of struct ACTIONS I have a recursive qsort/mergesort hybrid that 1) i'm not a 100% sure works correctly 2) would like to convert to iteration Any comments or...
22
by: Jeff Louie | last post by:
Well I wonder if my old brain can handle threading. Dose this code look reasonable. Regards, Jeff using System; using System.Diagnostics; using System.IO; using System.Threading;
5
by: James Radke | last post by:
Hello, I am using some external functions supplied by an ERP vendor in a windows.forms application (vb.net, visual studio.net 2003) The functions are defined as follows: ' Max startup and...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
5
by: JDS | last post by:
Hi. I have installed the PCNTL functions on my PHP enabled webserver in the interest of being able to fork a process into the background so I can do some heavy processing but return control of the...
6
by: D | last post by:
Hello all...I have an issue with one of my java script functions that I'm hoping someone can easily help with. I have a web based application that we use to create/sign up for overtime. When we...
5
by: Mirxon | last post by:
Hello, I'm working on a C program under Ubuntu. It's basd on socket. Browser calls a client cgi (C program), and send some parameters to server (C program). Server runs another program...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.