How can I capture the stdout output of a child process?,sys.stdout.flush()