Perl: Event-driven Programming
Posted
by Shiftbit
on Stack Overflow
See other posts from Stack Overflow
or by Shiftbit
Published on 2010-04-03T02:17:35Z
Indexed on
2010/04/03
2:23 UTC
Read the original article
Hit count: 507
Is there any POSIX signals that I could utilize in my perl program to create event-driven programming? Currently I have multi-process program that is able to cross communicate but my parent thread is only able to listen to listen at one child at a time.
foreach (@threads) {
sysread(${$_}{'read'}, my $line, 100);
chomp($line);
print "Parent hears: $line\n";
}
The problem is that the parent sits in a continual wait state until it receives it a signal from the first child before it can continue on. I am relying on 'pipe' for my intercommunication.
My current solution is very similar to: http://stackoverflow.com/questions/2558098/how-can-i-use-pipe-to-facilitate-interprocess-communication-in-perl
If possible I would like to rely on a $SIG{...} event or any non-CPAN solution.
© Stack Overflow or respective owner