use waitpid() rather than wait()