On 6/14/07, Bob McConnell <[EMAIL PROTECTED]> wrote:
snip
Assuming I can update to ActivePerl 5.8.8.820, if I set an alarm in one
forked process (thread?) before calling sysread() or sleep() on Win32,
will the same process receive the wakeup?
Looks like yes:
#!/usr/bin/perl
use strict;
use warnings;
my $pid = fork;
die "couldn't fork" unless defined $pid;
my ($name, $wait);
if ($pid) {
($name, $wait) = ("parent ", 10)
} else {
($name, $wait) = ("child ", 1)
}
print "$name" . localtime() . "\n";
eval {
local $SIG{ALRM} = sub { die "timeout $name\n" };
alarm $wait;
print "$name waiting $wait seconds\n";
while (1) {}
};
print $@ if $@;
print "$name" . localtime() . "\n";
parent Thu Jun 14 13:11:43 2007
parent waiting 10 seconds
child Thu Jun 14 13:11:43 2007
child waiting 1 seconds
timeout child
child Thu Jun 14 13:11:44 2007
timeout parent
parent Thu Jun 14 13:11:53 2007
Can I also send it a signal to
wake it up from another process?
In theory you should be able to use kill to send the ALRM signal to
another process. I have not tried it.
For the next step in this project I
have to split send and receive into two threads in order to handle a
full duplex connection. The ACK/NAK can be embedded anywhere in the
incoming data stream.
Bob McConnell
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/