Path: utzoo!utgpu!watserv1!ria!ria.ccs.uwo.ca!clipper From: clipper@chan.csd.uwo.ca (Khun Yee Fung) Newsgroups: comp.lang.perl Subject: Re: How to do alarm()? Message-ID: Date: 31 Oct 90 10:47:36 GMT References: <1990Oct31.041758.15623@uvaarpa.Virginia.EDU> Sender: news@ria.ccs.uwo.ca Organization: University of Western Ontario, Department of Computer Science Lines: 40 In-reply-to: telxon!ping!gorpong@uunet.uu.net's message of 31 Oct 90 04:17:58 GMT Thank you very much for the code to do alarm(). I tried both of them and they both worked. Thank you Larry for adding it in the next patch. I also found the error I committed when I used the various codes written by others and myself, all using syscall(). I used a return statement in the interrupt subroutine. It produced a Segmentation fault error. If I used a return statement in the code written by , the same error would be produced (on my machine anyway). I wonder why. Anybody has any idea? Just curious. #! /usr2/new/bin/perl # Interval to re-read the information, in seconds $interval = 1; # Set the timer to go off in 1 second, and every $interval seconds # thereafter. Call &get_info when it goes off. require 'syscall.h'; $SIG{'ALRM'} = 'get_info'; $value = pack('LLLL', $interval, 0, 1, 0); syscall(&SYS_setitimer, 0, $value, 0); while (1) { } sub get_info { print "get_info\n"; # Have a return here will produce a Segmentation fault error on a # sun 3/50 running SunOS 4.03 # return; } -- ---- In Real life: Khun Yee Fung clipper@csd.uwo.ca (Internet) Alternative: 4054_3267@UWOVAX.BITNET UUCP: ...!{ihnp4|decvax|seismo}!{watmath|utzoo}!ria!csd!clipper Department of Computer Science Middlesex College The University of Western Ontario London, Ontario, N6A 5B7 CANADA