Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Perl needs setjmp/longjmp Message-ID: <11212@jpl-devvax.JPL.NASA.GOV> Date: 28 Jan 91 23:19:59 GMT References: <120444@uunet.UU.NET> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 31 In article <120444@uunet.UU.NET> rbj@uunet.UU.NET (Root Boy Jim) writes: : Larry, we really need setjmp/longjmp. Otherwise, how can I : interrupt reads with alarms? On 4.2 BSD systems, reads are : automatically restarted. You basically have setjmp/longjmp in eval/die. See if you can make that work before we talk about setjmp/longjmp. Remember that the eval could be as simple as eval '&realcode'; Something like this: $SIG{'ALRM'} = 'TIMEOUT'; sub TIMEOUT { die "restart input\n"; } do { eval '&realcode'; } while $@ =~ /^restart input/; sub realcode { alarm 15; $ans = ; } : My incredibly ugly kluge around this is to TIOCSTI : a special "timeout character" into the input stream. I always thought that was a particularly elegant way to handle it. Ah well... Larry