On Wed, Oct 15, 2008 at 02:01, Simon Wistow [EMAIL PROTECTED] wrote:
Child:
my ($msg, $sem_id) = get_message();
my $sem = IPC::Semaphore-new($sem_id);
if (0 == $sem-op(0, -1, IPC_NOWAIT)) {
do_something($message);
}
# If we're the last then clean up
On Thu, Oct 16, 2008 at 7:36 AM, Philip Newton [EMAIL PROTECTED] wrote:
On Wed, Oct 15, 2008 at 02:01, Simon Wistow [EMAIL PROTECTED] wrote:
Child:
my ($msg, $sem_id) = get_message();
my $sem = IPC::Semaphore-new($sem_id);
if (0 == $sem-op(0, -1, IPC_NOWAIT)) {
I have an IPC problem.
I have a parent process with a bunch of forked children.
The parent sits in a loop waiting for messages and occasionally passes
them onto the children which are also sitting in their own loops
listening for messages and then doing stuff with them.
Still with me?
Now
Isn't this exactly what semaphores are for?
http://perldoc.perl.org/IPC/Semaphore.html
(http://en.wikipedia.org/wiki/Semaphores)
I'm sure you know all this so I suspect I've misread your question :-)
P
On Tue, Oct 14, 2008 at 11:21 PM, Simon Wistow [EMAIL PROTECTED] wrote:
I have an IPC
On Tue, Oct 14, 2008 at 11:39:22PM +0100, Paul Makepeace said:
Isn't this exactly what semaphores are for?
http://perldoc.perl.org/IPC/Semaphore.html
(http://en.wikipedia.org/wiki/Semaphores)
Hah! The original subject of my post was IPC and semaphores but I
changed it lest I do one of those
On Wed, Oct 15, 2008 at 12:08:43AM +0100, me said:
Tell a lie, what I want is
Parent:
my $id = $message-id;
my $n = scalar(@children);
my $sem = IPC::Semaphore-new(IPC_PRIVATE, 2, IPC_CREAT);
$sem-setall(1, $n-1);
foreach my $child (@children) {