There is always the possibility that either the driver accidentally waits for a condition that will never occur or that the condition will not happen for a long time. In either case, the user can abort the thread by sending it a signal. Whether the signal causes the driver to wake up depends upon the driver.
cv_wait_sig(9F) allows a signal to unblock the thread. This enables the user to break out of potentially long waits by sending a signal to the thread with kill(1) or by typing the interrupt character. cv_wait_sig(9F) returns zero if it is returning because of a signal, or nonzero if the condition occurred.
Example 3–3 shows how to use cv_wait_sig(9F) to allow a signal to unblock the thread.
mutex_enter(&xsp->mu);
while (xsp->busy) {
if (cv_wait_sig(&xsp->cv, &xsp->mu) == 0) {
/* Signalled while waiting for the condition */
/* tidy up and exit */
mutex_exit(&xsp->mu);
return (EINTR);
}
}
xsp->busy = 1;
mutex_exit(&xsp->mu);