Update wait.c

implements wait functions