Read the man pages (section 2) for the sleep and wait functions. Type "man 2 wait" and "man 2 sleep".