fix misuse of waitpid()