Path: utzoo!utgpu!attcan!lsuc!dave
From: dave@lsuc.uucp (David Sherman)
Newsgroups: comp.unix.wizards
Subject: sleep(3) uses longjmp and SIGALRM
Message-ID: <1988Sep28.135914.25444@lsuc.uucp>
Date: 28 Sep 88 17:59:11 GMT
Organization: Law Society of Upper Canada, Toronto
Lines: 24

I have a fairly complex CAI system that's used for legal education
here. It uses pipes, longjmp, SIGUSER and pause(2) to allow the student
to hit an interrupt key and change the level of instruction at any point.
It also uses sleep(3) here and there, and SIGALRM to log off idle users.
With all the various UNIXisms that interact, the programs occasionally
exhibit strange behaviour, which I'd never been able to pinpoint.

Today someone asked me why sleep(3) is a library routine rather
than a system call, which I'd always thought it was.  (This is a
v7-based UNIX, Perkin-Elmer's Edition VII.)  So I read the code,
and was startled to find it uses SIGALRM and pause, with a longjmp
to put you back where you were.

No wonder I get funny interactions with my other uses of setjmp
and SIGALRM.  I'm surprised some of it works at all.

The manual doesn't suggest sleep(3) shouldn't be used in conjunction
with setjmp or SIGALRM.  But setjmp's certainly aren't nestable.
Has anyone else run into this issue?  Comments?

David Sherman
The Law Society of Upper Canada
-- 
{ uunet!attcan  att  pyramid!utai  utzoo } !lsuc!dave