RE: Having trouble porting an application to MS-Windows



-----Original Message-----
From: Chas Owens [mailto:chas.owens@xxxxxxxxx]
Sent: Friday, June 15, 2007 10:55 AM
To: Bob McConnell
Cc: beginners@xxxxxxxx
Subject: Re: Having trouble porting an application to MS-Windows

On 6/15/07, Bob McConnell <rvm@xxxxxxxxx> wrote:
snip
eval {
local $SIG{ALRM} = sub { die
"alarm\n" }; # NB:
\n required
alarm $timeout;
$nread = sysread PORT, $line, 1;
alarm 0;
};
snip
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?
snip

Hmm, that codes looks right. Do the two scripts I sent earlier work?


Yes, both work with the output below. The difference is that both of
yours interrupt an empty while loop, but my code is in a sysread() call.
The SIGINT I use to kill the process can interrupt the system call, but
will the alarm? Or have I found a bug in the ActiveState implementation?

Bob McConnell

D:\Perl\eg\SIMscript>perl forka.pl
Fri Jun 15 11:16:36 2007
timeout
Fri Jun 15 11:16:39 2007

D:\Perl\eg\SIMscript>perl forkb.pl
parent Fri Jun 15 11:12:57 2007
parent waiting 10 seconds
child Fri Jun 15 11:12:57 2007
child waiting 1 seconds
timeout child
child Fri Jun 15 11:12:58 2007
timeout parent
parent Fri Jun 15 11:13:07 2007
.



Relevant Pages

  • Question about building perl-5.8.5 multi-threaded on RedHat 9 Linux
    ... obtained initial lock ... child obtained lock ... ok 18 - cond_wait [twain]: ... timeout: ...
    (comp.lang.perl.misc)
  • Re: Time out question
    ... There are quite a lot of problems with alarm() ... from time_limit import time_limit, TimeOut ... raise TimeOut() ... # Install new handler remembering old ...
    (comp.lang.python)
  • Re: Bash: command output to variable
    ... ReadMode "normal"; ... # reads key with a timeout of 5 seconds without echo ... alarm $timeout; ... # if the Perl syntax error message string exists and is not ...
    (comp.unix.shell)
  • Re: Bash: command output to variable
    ... list top 10 cpu intensive processes. ... An optimized perl solution: ... # reads a key without echo and with a timeout of $timeout seconds ... alarm $timeout; ...
    (comp.unix.shell)
  • Re: creating a socket connection timeout in "C" linux
    ... What makes alarm() unreliable? ... The 'easy, unreliable timeout' is setting ... the SIGALRM may actually be posted to the process before the connect ... Relying on SIGALRM to interrupt a blocked system call could ...
    (comp.unix.programmer)