in reply to Re: script suicide?
in thread script suicide?

Hmm, trying this in a small test script didn't seem to work. Which means I'm probably not doing it right.
The code below would make me think that it will print that out for 5 seconds and then stop via the exit call.
Instead it just runs and runs, happy as can be.
$SIG {ALRM} = sub {exit}; alarm (5); while(1){ print "hairy fishnuts\n"; }
"perl -v" tells me "This is perl, v5.6.1 built for i386-freebsd"

What am I doing wrong?

There are some odd things afoot now, in the Villa Straylight.

Replies are listed 'Best First'.
Re: script suicide?
by Abigail-II (Bishop) on Jul 21, 2003 at 14:04 UTC
    You either have a bug in your particular installation of Perl, or in the OS (I tried it with the same version of Perl, but different OS), or you aren't patient enough. Did you by any chance run this without redirecting standard output? Then it might take more seconds, and if you do this remotely, and have a slow network, it even takes more time. For me, the program gets aborted after 5 seconds if I redirect output - but it takes 8 seconds before getting a prompt if I don't redirect output. With a slow network, or a slow terminal, it might take minutes.


      Ahh, ye' ol' slow network. That would be the key here. I set it to alarm(1) and then just let it run and that worked just dandily over time.
      I am indeed on a very slow network here (128K frame relay shared between 16 people and 3 servers - blech).

      Thank you very much for the help. I'm gonna go flagellate myself now like a proper monk - that'll teach me for not heeding slow networks.
      Thanks again :)

      There are some odd things afoot now, in the Villa Straylight.