fix infinite waitpid loop