Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site calgary.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!alberta!calgary!andrews From: andrews@calgary.UUCP (Keith Andrews) Newsgroups: net.unix-wizards,net.sources Subject: Re: When does ( alarm(1) == alarm(INFINITY) ) ? Message-ID: <1095@calgary.UUCP> Date: Fri, 8-Mar-85 10:37:13 EST Article-I.D.: calgary.1095 Posted: Fri Mar 8 10:37:13 1985 Date-Received: Sun, 10-Mar-85 06:33:09 EST References: <132@heurikon.UUCP> <1094@calgary.UUCP> Organization: University of Calgary, Calgary, Alberta Lines: 61 Xref: watmath net.unix-wizards:12384 net.sources:2683 > I wrote the following fudge routine to handle a similar problem > when using 4.1 BSD. The 4.2 signal stuff allows a cleaner (though > less efficient) solution. It only works on the VAX as written, though > adaptation to other machines would probably be possible. > > > static char pause_routine[5]; /* Pause system call or nop's */ > > /* Set up a routine to do a "pause" system call. */ > > jk_set_up_pause() > { register char *p; > p = &pause_routine[2]; > *p++ = 0274; *p++ = 035; /* chmk $pause */ > *p++ = 04; /* ret */ > } > ........ > > jk_maybe_do_pause() > { (*(void (*)())pause_routine)(); > } > > /* Disable pause call by replacing system call with nop's */ > > jk_disable_pause() > { register char *p; > p = &pause_routine[2]; > *p++ = 01; *p++ = 01; /* nop; nop */ > } Although this solution to the problem may be sound, this method of implementing it is, er... dumb (to say the least). The following implementation is much easier to understand, simpler and (Oh wow!) portable: int (*foo)(); int pause(); ... { ... /* Point at the pause() call */ foo = pause; /* Set up alarm */ alarm(1); /* Actually do pause (well, maybe) */ (*foo)(); /* Proceed merrily along */ } int null() {} /* Do nothing function */ alarm_signal_handler() { foo = null; } Keith Andrews U of Calgary, Dept. of CS