Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!ncar!gatech!mcnc!uvaarpa!mmdf From: worley@compass.uucp (Dale Worley) Newsgroups: comp.lang.perl Subject: How to do alarm()? Message-ID: <1990Oct30.194343.27499@uvaarpa.Virginia.EDU> Date: 30 Oct 90 19:43:43 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: worley@compass.uucp Organization: The Internet Lines: 25 Well, here's the code I use: #! /usr/local/bin/perl # Interval to re-read the information, in seconds $interval = 60; # Set the timer to go off in 1 second, and every $interval seconds # thereafter. Call &get_info when it goes off. do '/compass/c/worley/perl-3.0/sys/syscall.h'; $SIG{'ALRM'} = 'get_info'; $value = pack('LLLL', $interval, 0, 1, 0); syscall(&SYS_setitimer, 0, $value, 0); (Of course, you have to use the correct directory for your syscall.h Perl header file.) The crux of the problem is that alarm() isn't a system call, it is a library routine that calls setitimer() (on BDS 4.2 systems, anyway). You can do setitimer() pretty straightforwardly using Perl's syscall(). Don't forget that the name of the signal is ALRM, not ALARM! (Elements of %SIG that don't correspond to real signal names have no effect...) Dale Worley Compass, Inc. worley@compass.com -- I try to make everyone's day a little more surreal.