+ /* + * We allow nanosleep to handle interrupts and retry with the remaining time. + * However, since nanosleep is susceptible to time drift when interrupted + * frequently, we add a safeguard to break out of the nanosleep whenever the + * total time of the sleep exceeds the requested sleep time. Using nanosleep + * is a more portable approach than clock_nanosleep. + */
I'm curious why we wouldn't just subtract "elapsed_time" from "delay" at the bottom of the while loop to avoid needing this extra check. Also, I think we need some commentary about why we want to retry after an interrupt in this case. -- nathan