fix use of waitpid