added diagnostic output for waitpid