sleep(3) uses longjmp and SIGALRM
Dave Jones
djones at megatest.UUCP
Fri Sep 30 07:30:26 AEST 1988
>From article <1988Sep28.135914.25444 at lsuc.uucp), by dave at lsuc.uucp (David Sherman):
) 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.
The man-page on the Sun3 (BSD4.2 based) is explicit:
sleep is implemented by setting an interval timer and paus-
ing until it expires. The previous state of this timer is
saved and restored.
I would recommend that you process all signals, sleeps, selects, etc,
through a central location. The "notifier" in Sun's sunview package
would suffice, but I don't know if its source is available. In
any case, it should not be too difficult to implement it.
Good luck.
More information about the Comp.unix.wizards
mailing list