wait for child process termination in a different thread