Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

alarm() implemented?

2 views
Skip to first unread message

spark

unread,
Jan 29, 2003, 11:23:37 AM1/29/03
to
Is alarm() implemented for Win32 in the latest version of Perl?

spark

unread,
Jan 29, 2003, 11:56:17 AM1/29/03
to
In article <MPG.18a1bbf08...@news-central.giganews.com>,
sp...@dcwis.nodurnspam.com says...

> Is alarm() implemented for Win32 in the latest version of Perl?
>

Nevermind, I see it isn't.

I have a script that uses system() to execute a command line which
compacts an Access database. This command never returns anything other
than 0, on success or failure. Generally though, if the task fails it
will just hang (return nothing). What I would like to do is create some
kind of alarm process which will wait so long for that 0 return value,
and if it doesn't get it in that time, just continue with the rest of
the script. If anyone can tell me of a way I might do that or a module
that will help me, I'd appreciate it.

thanks in advance
spark

Mothra

unread,
Jan 29, 2003, 2:01:00 PM1/29/03
to

> sp...@dcwis.nodurnspam.com says...
> > Is alarm() implemented for Win32 in the latest version of Perl?
> >
>
> Nevermind, I see it isn't.
What version of perl did you try? I am running version 5.8.0 and
it is implemented.

use strict;
use warnings;

print " perl version is $]\n";
$SIG{ALRM} = sub { die "timeout" };

eval {
alarm(3);
sleep (6);
alarm(0);
};

if ($@) {
if ($@ =~ /timeout/) {
print "Yep!! it timed out\n"; # timed out; do
what you will here
} else {
alarm(0); # clear the still-pending alarm
die; # propagate unexpected exception
}
}

output isF:\scripts>time.pl
perl version is 5.008
Yep!! it timed out

F:\scripts>

Hope this helps

Mothra

spark

unread,
Jan 29, 2003, 2:23:36 PM1/29/03
to
In article <3e382413$1...@usenet.ugs.com>, mot...@nowhereatall.com says...

>
> > sp...@dcwis.nodurnspam.com says...
> > > Is alarm() implemented for Win32 in the latest version of Perl?
> > >
> >
> > Nevermind, I see it isn't.
> What version of perl did you try? I am running version 5.8.0 and
> it is implemented.

Oh - I went to activestate and looked up the perlport page there. I
assumed it was for 5.8. If it's working for you, I'll try 5.8 (I'm on
5.6). Thanks!

spark

Sisyphus

unread,
Jan 29, 2003, 9:51:34 PM1/29/03
to
spark <sp...@dcwis.nodurnspam.com> wrote in message news:<MPG.18a1bbf08...@news-central.giganews.com>...

> Is alarm() implemented for Win32 in the latest version of Perl?

Seems to be impemented to some degree, at least.

With 5.8:
perl -e "alarm(2);for(;;){}"
That will produce (after a couple of seconds) the message:
Terminating on signal SIGALRM(14)
Then exits immediately.

With 5.6.1
perl -e "alarm(2);for(;;){}"
That will exit immediately with the message:
The Unsupported function alarm function is unimplemented at -e line 1.

Just how far the support extends, I don't know :-)

Cheers,
Rob

Dr. Peter Dintelmann

unread,
Jan 30, 2003, 4:09:53 AM1/30/03
to
Hik

"spark" <sp...@dcwis.nodurnspam.com> schrieb im Newsbeitrag
news:MPG.18a1bbf08...@news-central.giganews.com...


> Is alarm() implemented for Win32 in the latest version of Perl?

perl -MConfig -le 'print $Config{d_alarm}'

(use "" on Win32) shows, wether alarm() is available.

HTH,

Peter Dintelmann


0 new messages