[comp.lang.perl] Perl needs setjmp/longjmp

rbj@uunet.UU.NET (Root Boy Jim) (01/29/91)

Larry, we really need setjmp/longjmp. Otherwise, how can I
interrupt reads with alarms? On 4.2 BSD systems, reads are
automatically restarted.

My incredibly ugly kluge around this is to TIOCSTI
a special "timeout character" into the input stream.
-- 

	Root Boy Jim Cottrell <rbj@uunet.uu.net>
	Close the gap of the dark year in between

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (01/29/91)

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 = <STDIN>;
	}

: 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