> if ( $timenow - $start >= $delay ) {
> $start = $t;
> dumpstats($err);
> $err = {};
> }
> }
> ...
>
> I wonder if it would be possible to replace this loop with a handler
> based on alarm.
> If it is possible, which
> if ( $timenow - $start >= $delay ) {
> $start = $t;
err, that would be:
$start = $timenow;
> dumpstats($err);
> $err = {};
> }
> }
> ...
>
> I wonder if it would be possible to replace this loop w
$err = {};
}
}
...
I wonder if it would be possible to replace this loop with a handler
based on alarm.
If it is possible, which would be more efficient?
Thanks
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
ntents of variable using alarm()
>
> On Fri, Aug 20, 2010 at 04:34, Kammen van, Marco, Springer SBM NL
> wrote:
>> Hi All,
>>
>> I want to use timers to check if certain variables are set and if not
>> send some data back to a client...
>>
>> Been
Original Message-
From: Chas. Owens [mailto:chas.ow...@gmail.com]
Sent: Friday, August 20, 2010 4:07 PM
To: Kammen van, Marco, Springer SBM NL
Cc: beginners@perl.org
Subject: Re: test contents of variable using alarm()
On Fri, Aug 20, 2010 at 04:34, Kammen van, Marco, Springer SBM NL
On Fri, Aug 20, 2010 at 04:34, Kammen van, Marco, Springer SBM NL
wrote:
> Hi All,
>
> I want to use timers to check if certain variables are set and if not
> send some data back to a client...
>
> Been searching for this a while now, but all I can find on alarm are
> e
Hi All,
I want to use timers to check if certain variables are set and if not
send some data back to a client...
Been searching for this a while now, but all I can find on alarm are
examples on timing out commands
So something like:
sub timeout {
$timeout = 5;
eval
On Tue, 2009-07-14 at 10:58 -0400, Chas. Owens wrote:
> You just removed a major feature of the code. Do you want to explain
> why your paranoia has lead you to remove the ability to override the
> default $timedout and $error handlers? I could understand if your
> paranoia lead you to check to m
On Tue, Jul 14, 2009 at 07:01, Shawn H. Corey wrote:
> On Mon, 2009-07-13 at 23:49 -0400, Chas. Owens wrote:
>> #!/usr/bin/perl
>>
>> use strict;
>> use warnings;
>>
>> sub timeout {
>> my ($wait, $code, $timedout, $error) = (@_,
>> sub { warn $@ }, sub { die $@ });
>
> # I'
ass
my ( $wait, $code ) = @_;
my ( $timeout, $error ) = ( sub { warn $@ }, sub { die $@ } );
>
> eval {
> local $SIG{ALRM} = sub { die "timeout\n" };
> alarm $wait;
> $code->();
>
On Mon, Jul 13, 2009 at 22:57, Jenn G. wrote:
> Hello,
>
> From the code below:
>
> eval {
> local $SIG{ALRM} = sub { die "TIMEOUT\n" };
> alarm($seconds);
> ... code to execute with timeout here ...
> alarm(0); # cancel alarm (if code ran fast)
Hello,
>From the code below:
eval {
local $SIG{ALRM} = sub { die "TIMEOUT\n" };
alarm($seconds);
... code to execute with timeout here ...
alarm(0); # cancel alarm (if code ran fast)
};
alarm(0);# cancel alarm (if eval failed)
Is the second alarm(0) need
On Wed, Apr 1, 2009 at 20:28, wrote:
> Away from PC so I cannot hookup
> Is alarm perls internal function?
snip
The alarm function is part of Core Perl.
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: beg
Away from PC so I cannot hookup
Is alarm perls internal function?
-Original Message-
From: "Chas. Owens"
Date: Wed, 1 Apr 2009 10:18:51
To: Kelly Jones
Cc:
Subject: Re: Calling subroutine every second using alarm fails
On Wed, Apr 1, 2009 at 08:48, Kelly Jones wrote:
On Wed, Apr 1, 2009 at 08:48, Kelly Jones wrote:
> I want a script that constantly accepts user input, but runs a
> subroutine every second to do other work. My attempt:
>
> $|=1; $SIG{'ALRM'}= "\&alarm_sub"; &alarm_sub;
> while (<>) {print &qu
>> Original Message
>> Subject: Calling subroutine every second using alarm fails
>> From: Kelly Jones
>> Date: Wed, April 01, 2009 5:48 am
>> To: beginners@perl.org
>>
>>
>> I want a script that constantly accepts user input, b
> Original Message
> Subject: Calling subroutine every second using alarm fails
> From: Kelly Jones
> Date: Wed, April 01, 2009 5:48 am
> To: beginners@perl.org
>
>
> I want a script that constantly accepts user input, but runs a
> subroutine ev
I want a script that constantly accepts user input, but runs a
subroutine every second to do other work. My attempt:
$|=1; $SIG{'ALRM'}= "\&alarm_sub"; &alarm_sub;
while (<>) {print "You typed: $_\n";}
sub alarm_sub {print "ALARM!\n"; alarm 1;
"Matthew Tice" schreef:
> eval {
> local $SIG{ALRM} = sub {die "alarm\n"};
> alarm 2;
> $test = `ls @ARGV[0]`;
> alarm 0;
> };
>
> if ($@) {
> die unless $@ eq "alarm\n";
> # Timed out - error
> exit 1;
> } else {
&g
@ARGV < 1) {
print "Usage:\n";
print "$0 \n";
exit 1;
}
eval {
local $SIG{ALRM} = sub {die "alarm\n"};
alarm 2;
$test = `ls @ARGV[0]`;
If you had warnings enabled then perl would have told you to use
$ARGV[0] instead of @ARGV[0].
Why are you
print "$0 \n";
exit 1;
}
eval {
local $SIG{ALRM} = sub {die "alarm\n"};
alarm 2;
$test = `ls @ARGV[0]`;
alarm 0;
};
if ($@) {
die unless $@ eq "alarm\n";
# Timed out - error
exit 1;
} else {
# Okay
exit 0;
}
However, on the machine that experienced th
l the code in $cmd, using either system() or exec(), a shell will
be spawned to execute the code. We'll call that sh(1). The code
executed by sh(1) contains the shell command 'perl' to which you pass
the runtime flag -e and the argument 'alarm(5); exec...'. That causes
the s
On Feb 5, 9:26 pm, [EMAIL PROTECTED] (Rob Dixon) wrote:
> [EMAIL PROTECTED] wrote:
> > I am using perl alarm within a script and having an issue. I want to
> > access a host by first trying rsh and if that fails use ssh. I can
> > get the command to run with only one of th
[EMAIL PROTECTED] wrote:
I am using perl alarm within a script and having an issue. I want to
access a host by first trying rsh and if that fails use ssh. I can
get the command to run with only one of the commands but when I add
both it fails. I must be missing something simple
Here is the
On Feb 5, 2008 10:22 AM, <[EMAIL PROTECTED]> wrote:
> I am using perl alarm within a script and having an issue. I want to
> access a host by first trying rsh and if that fails use ssh. I can
> get the command to run with only one of the commands but when I add
> both it
I am using perl alarm within a script and having an issue. I want to
access a host by first trying rsh and if that fails use ssh. I can
get the command to run with only one of the commands but when I add
both it fails. I must be missing something simple
Here is the info:
Part of script
On 6/6/06, Chas Owens <[EMAIL PROTECTED]> wrote:
I used "unless" because flock returns 0 on
success and -1 on failure (unless it doesn't work like C version).
Nope; it works like Perl. :-) A true value for success, false for failure.
Cheers!
--Tom Phoenix
Stonehenge Perl Training
--
To uns
"busy wait": You're keeping the CPU busy during
the retries (which is one more than $maxtries). Instead, use sleep()
or the four-argument select() to let other processes use the CPU while
you're waiting.
As to the original problem, some systems may not support using alarm()
to i
ne more than $maxtries). Instead, use sleep()
or the four-argument select() to let other processes use the CPU while
you're waiting.
As to the original problem, some systems may not support using alarm()
to interrupt system calls like flock(), because (I believe) of the way
that flock() is emulat
On 6/6/06, Jeff Pang <[EMAIL PROTECTED]> wrote:
Hello,lists,
See these code piece please:
while ($cycles--)
{
my $c;
eval {
local $SIG{ALRM} = sub { die "flock timeout" };
alarm 3;
open (SOCKLOCK,SOCK_LOCK) or die
Hello,lists,
See these code piece please:
while ($cycles--)
{
my $c;
eval {
local $SIG{ALRM} = sub { die "flock timeout" };
alarm 3;
open (SOCKLOCK,SOCK_LOCK) or die "open lock file fail: $!";
flo
On 11/22/05, Tom Allison <[EMAIL PROTECTED]> wrote:
> John Doe wrote:
> > Tom Allison am Dienstag, 22. November 2005 12.24:
> >
> >>I figured out I can do this:
> >>
> >>eval {
> >> local $SIG{ALRM} = sub { warn("alarm\n"
Tom Allison am Dienstag, 22. November 2005 20.59:
> John Doe wrote:
> > Tom Allison am Dienstag, 22. November 2005 12.24:
> >>I figured out I can do this:
> >>
> >>eval {
> >>local $SIG{ALRM} = sub { warn("alarm\n") };
>
John Doe wrote:
Tom Allison am Dienstag, 22. November 2005 12.24:
I figured out I can do this:
eval {
local $SIG{ALRM} = sub { warn("alarm\n") };
alarm 1;
for(my $j = 0; $j < 1_000_000, $j++) {
my $x = log(rand()*1000+1);
}
Tom Allison am Dienstag, 22. November 2005 12.24:
> I figured out I can do this:
>
> eval {
> local $SIG{ALRM} = sub { warn("alarm\n") };
> alarm 1;
> for(my $j = 0; $j < 1_000_000, $j++) {
> my $x = log(rand()*1000+1);
&g
I figured out I can do this:
eval {
local $SIG{ALRM} = sub { warn("alarm\n") };
alarm 1;
for(my $j = 0; $j < 1_000_000, $j++) {
my $x = log(rand()*1000+1);
}
alarm 0;
};
if ( $@ ) {
carp "[EMAIL PROTECTED]";
}
Hello,
This is odd ... if I use Proc::Simple to run the sub routine in the
background the alarm works fine. I then simple shutdown the second
process using Proc::Simple's kill function.
Michael
Michael Gale wrote:
Hello,
I am having a problem with the following piece of
t
occured".
But with use of the alarm function, should it not be exiting after 10
seconds even if a packet has not been received ??
--snip--
&packet_cap_setup();
eval {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm 10;
Net::Pcap::loop($pc
I am currently using
>> alarm to enforce the timeout, but I don't want the script to die. I
>> want a way to be able to gracefully move onto a different part of the
>> script or return some value.
>
> --As for the rest, it is mine.
>
> What you need to do i
--As off Tuesday, February 3, 2004 10:09 AM -0700, Sam Masiello is
alleged to have said:
I have a script where I am sending some data over a socket, but
after X seconds I want the operation to time out. I am currently
using alarm to enforce the timeout, but I don't want the script to
di
Hi all!
I am new to the list, and have a question which I hope isn't too
difficult to answer.
I have a script where I am sending some data over a socket, but after X
seconds I want the operation to time out. I am currently using alarm to
enforce the timeout, but I don't want the scr
he question..
>> >
>> > I'm trying to use perl to read a file and then run a program using the
>> > file. I also want to use the alarm(x) function to skip to the next
>> > entry in the files if it times out. Here's what Ive go so far:
[...]
>> D
Keven.. This looks really good..
Is it the "eval" that keeps the alarm from kicking the script out of the
loop?
I can tell I'll have some reading to do in the morning..
On Sat, 12 Jul 2003, Kevin Pfeiffer wrote:
> In article <[EMAIL PROTECTED]>,
> [EMAI
Maybe I'm missing something.. But when the alarm triggers, the program
drops out of the loop.. I think this is normal, what I need is for the
next line of the file to be read. I'm I wrong here?
On 14 Jul 2003, Ramprasad A Padmanabhan wrote:
>
> On Sat, 2003-07-12 at 20:34,
On Sat, 2003-07-12 at 20:34, [EMAIL PROTECTED] wrote:
> This will work, but wont solve the problem of the alarm exiting the loop
> before the file has been totaly proccessed.
>
Seems to me that it is exactly what is wanted
> On Sat, 12 Jul 2003, Ramprasad wrote:
>
>
This will work, but wont solve the problem of the alarm exiting the loop
before the file has been totaly proccessed.
On Sat, 12 Jul 2003, Ramprasad wrote:
> [EMAIL PROTECTED] wrote:
> > I'm kind of new to Perl, so please forgive the question..
> >
> > I'm trying
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] wrote:
Hi,
> I'm kind of new to Perl, so please forgive the question..
>
> I'm trying to use perl to read a file and then run a program using the
> file. I also want to use the alarm(x) function to skip to the nex
[EMAIL PROTECTED] wrote:
I'm kind of new to Perl, so please forgive the question..
I'm trying to use perl to read a file and then run a program using the
file. I also want to use the alarm(x) function to skip to the next entry
in the files if it times out. Here's what Ive g
I'm kind of new to Perl, so please forgive the question..
I'm trying to use perl to read a file and then run a program using the
file. I also want to use the alarm(x) function to skip to the next entry
in the files if it times out. Here's what Ive go so far:
open (TESTFILE
On Mon, 10 Feb 2003 12:41:57 +0100, [EMAIL PROTECTED] (Angerstein)
wrote:
>If I need an alarm signal alarm(), in less than 1 second what can I do?
Interestingly enough, this just showed up on perlmonks this morning.
http://www.perlmonks.org/index.pl?node_id=23402
Simultaneous alarms unde
On Feb 10, Angerstein said:
>sub selfalarm {
> $waittime = @_;
Above is your problem. You are assigning the NUMBER of elements in @_ to
$waittime, not the first element. Use one of the following:
my $waittime = shift;
my ($waittime) = @_;
my $waittime = $_[0];
>$ppid = getppid();
>
This is a FAQ :
C:\>perldoc -q alarm
Found in C:\Perl\lib\pod\perlfaq8.pod
How can I sleep() or alarm() for under a second?
If you want finer granularity than the 1 second that the sleep()
function provides, the easiest way is to use the select()
function
Hello,
I have aquestions.
If I need an alarm signal alarm(), in less than 1 second what can I do?
Would that work?
sub selfalarm {
$waittime = @_;
if ($pid = fork){
} else {
$ppid = getppid();
select (undef,undef,undef, $waittime);
kill 14 => ppid;
}
}
SIG{A
Date sent: Fri, 20 Dec 2002 13:00:59 -0500
From: Ian Zapczynski <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject:how to use alarm() to properly time out a connection?
> I need to use alarm to time out a connection t
>
> eval {
> $sftp = Net::SFTP->new($FTPHOST, user=>$FTPUSER,
> password=>$FTPPASS);
> local $SIG{ALRM} = sub { die "alarm\n" };
> alarm 60;
> };
>
> if ($@) {
> &sendSNMP unless $@ eq &
Jose,
Yes, you are correct. I did not know about placing the alarm prior to
the hanging condition (gee, I guess that makes sense) or clearing the
alarm afterwards. Thank you!
-Ian
NYIMI Jose (BMB) wrote:
-Original Message-
From: Ian Zapczynski [mailto:[EMAIL PROTECTED]]
Sent
> -Original Message-
> From: Ian Zapczynski [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 20, 2002 7:01 PM
> To: [EMAIL PROTECTED]
> Subject: how to use alarm() to properly time out a connection?
>
>
> Hello all,
>
> I need to use alarm to time out
Hello all,
I need to use alarm to time out a connection to an SFTP server if the
connection hangs (I was able to reproduce such a hang using the Secure
Shell Server for Windows, so I thought it would be nice if my script
assumed this was a possibility).
I think I am not understanding the
G{ALRM} = sub { $time_to_die=1; };
>
> alarm($timeout);
> while(!$time_to_die)
>
> {
> while (1)
Are you sure you want this infinite loop here?
> { foreach (@e)
> {
> print $_."\b";
> }
> }
> }
--
Paul Johnson -
ok, i tried in UNIX and got no more errors
but it doesnt expire after 30 seconds as expected.
-Original Message-From: Timothy Johnson
[mailto:[EMAIL PROTECTED]]Sent: Thursday, November 28, 2002 3:38
PMTo: 'Juban, Nix'; '[EMAIL PROTECTED]'Subject: RE:
It looks like you tried to use the alarm
function on a Win32 machine. Like your error message says, the alarm()
function is not supported on your system.
-Original Message-From: Juban, Nix
[mailto:[EMAIL PROTECTED]]Sent: Wednesday, November 27, 2002 8:49
PMTo: '[
I made the script below to have this line
tumbling like cartwheel and i want it to run for 30 seconds.
Im receiving the error, "The
Unsupported function alarm function is unimplemented at
C:\PERL\TRAINING\PERL\timedroutine.pl line 11" for the script below. Need help
in knowing
> -Original Message-
> From: jeff loetel [mailto:[EMAIL PROTECTED]]
> Sent: Friday, November 22, 2002 9:01 AM
> To: Perl beginners
> Subject: eval and alarm timeout for slow process (XML post)
>
>
> Does this look correct below. I know that I should test but
connection or a server down. I am using LWP and set the
timeout feature but it never really seemed to catch the situation.
Any feedback is welcome.
eval {
local $SIG{ALRM} = sub { die "timeout\n" };
alarm (60); # 60 sec. timeout
in my understanding of XML::Simple and
turning me into a die-hard fan of his module (a link to which is on
every page of my new website, http://www.theoretic.com).
Mr Irving, Mr McCoy, Mr Cope, and Mr Bach, for all helping me on
return(), 'use strict', and refrences. thank you!
Without these lists,
65 matches
Mail list logo