RE: Having trouble porting an application to MS-Windows
- From: rvm@xxxxxxxxx (Bob McConnell)
- Date: Fri, 15 Jun 2007 10:46:24 -0400
-----Original Message-----
From: Chas Owens [mailto:chas.owens@xxxxxxxxx]
Sent: Thursday, June 14, 2007 12:10 PM
To: Bob McConnell
Cc: beginners@xxxxxxxx
Subject: Re: Having trouble porting an application to MS-Windows
On 6/14/07, Chas Owens <chas.owens@xxxxxxxxx> wrote:
On 6/14/07, Bob McConnell <rvm@xxxxxxxxx> wrote:list of Perl
In "perlport - Writing portable Perl" in the Alphabetic
installed theFunctions:snip
alarm SECONDS
alarm
Not implemented. (Win32)
I couldn't find anything in the ActiveState release notes that
contradicted that.
snipthe latest version of ActiveState Perl on Windows XP works.
Are you using the latest version of ActiveState Perl? I
latest version this morning to test the code I sent and when I runatan2, and binmode.
perldoc -T perlport | find /i alarm
I get not output. The first three functions listed are -X,
In fact, the reference to alarm drops out of perlport in version 5.8.3
(released in 2004).
from Perl 5.8.3's Changes file
[ 21895]
alarm() is now implemented on Win32.
I still can't get it to work, even without the fork. I am now running
ActivePerl 5.8.8.820 on Win2K SP4. Here are the code snippets after
pasting in the recommended alarm handling:
-----------------------------------
$port = 'COM4' unless $port;
$SIG{'INT'} = 'dokill'; # this allows me to kill it with
CTRL-Break
sub dokill {
kill 9,$child if $child;
}
sysopen( PORT, "$port", O_RDWR ) or die "Can't sysopen $port: $!";
binmode(PORT);
LINE: while (<IN>) { # Input records from input file.
chomp;
# loop on NAK or timeout with two retries
$done = 0;
$tries = 0;
do {
syswrite PORT, $_, length;
$timeout = 3;
eval {
local $SIG{ALRM} = sub { die "alarm\n" }; # NB:
\n required
alarm $timeout;
$nread = sysread PORT, $line, 1;
alarm 0;
};
if ($@) {
die unless $@ eq "alarm\n"; # propagate
unexpected errors
# timed out
print STDOUT " t/o";
}
else {
fprint STDOUT "sysread returned %d.\n", $nread;
if (ord $line == 21) {
print STDOUT " NAK";
}
if (ord $line == 6) {
print STDOUT " ACK";
$done = 1;
}
}
} while ($done == 0 && ++$tries < 3);
print STDOUT "\n";
if ($done == 0) {
next LINE;
}
#send response and wait for ACK/NAK here
}
-----------------------------------
This transmits the packet, but never comes out of the eval() if it
doesn't receive a character. Is there anything obvious that I missed?
Even if this does work, can I set simultaneous alarms in multiple
threads?
Thank you,
Bob McConnell
.
- Follow-Ups:
- Re: Having trouble porting an application to MS-Windows
- From: Chas Owens
- Re: Having trouble porting an application to MS-Windows
- References:
- Having trouble porting an application to MS-Windows
- From: Bob McConnell
- Re: Having trouble porting an application to MS-Windows
- From: Chas Owens
- RE: Having trouble porting an application to MS-Windows
- From: Bob McConnell
- Re: Having trouble porting an application to MS-Windows
- From: Chas Owens
- Re: Having trouble porting an application to MS-Windows
- From: Chas Owens
- Having trouble porting an application to MS-Windows
- Prev by Date: Re: Comparing the Perl encrypted files
- Next by Date: Re: Having trouble porting an application to MS-Windows
- Previous by thread: Re: Having trouble porting an application to MS-Windows
- Next by thread: Re: Having trouble porting an application to MS-Windows
- Index(es):
Relevant Pages
|