From: utzoo!decvax!harpo!utah-cs!utah-gr!thomas
Newsgroups: net.unix-wizards
Title: Re: close problem on single-use devices
Article-I.D.: utah-gr.518
Posted: Mon Aug  9 09:36:30 1982
Received: Tue Aug 10 02:26:59 1982
References: sri-unix.2563

I've run into this and finally concluded that it was a result of the
close routine calling sleep() with an interruptable priority level. 
If a signal occurs during the sleep, the close is forcibly exited (with
a longjump) and any cleanup following the sleep never occurs.  On the
other hand, if the sleep is called with a non-interuptable priority
level, and the awaited event never occurs, there is no way to kill the
process.  The best solution I can think of is to sleep at a
non-interruptable level, but to invoke a timeout routine to terminate
the sleep after some reasonable period.  Messy, yes, but device
interactions always are.

=Spencer