wait function does not work with nanosleep - use nanosleep directly

The wait function attempts to wait until a point in the future, by checking
how much time has passed according to clock(). As clock does not advance
while the process is sleeping, it does not work correctly with nanosleep()