spawn('python''pipes-testchild py''spam'fork child program print('hello from parent'mypidsys stdout flush(reply input(sys stderr write('parent got"% "\nreplyto child' stdin subvert stdio buffering from child' stdout stderr not tied to pipeprint('hello from parent'mypidsys stdout flush(reply sys stdin readline(sys stderr write('parent got"% "\nreply[:- ]the spawn function in this module does not work on standard windows python (remember that fork isn' yet available there todayin factmost of the calls in this module map straight to unix system calls (and may be arbitrarily terrifying at first glance to non-unix developers!we've already met some of these ( os fork)but much of this code depends on unix concepts we don' have time to address well in this text but in simple termshere is brief summary of the system calls demonstrated in this codeos fork copies the calling process as usual and returns the child' process id in the parent process only os execvp overlays new program in the calling processit' just like the os execlp used earlier but takes tuple or list of command-line argument strings (collected with the *args form in the function headeros pipe returns tuple of file descriptors representing the input and output ends of pipeas in earlier examples os close(fdcloses the descriptor-based file fd os dup (fd ,fd copies all system information associated with the file named by the file descriptor fd to the file named by fd in terms of connecting standard streamsos dup is the real nitty-gritty here for examplethe call os dup (parentstdin,stdinfdessentially assigns the parent process' stdin file to the input end of one of the two pipes createdall stdin reads will henceforth come from the pipe by connecting the other end of this pipe to the child process' copy of the stdout stream file with os dup (childstdout,stdoutfd)text written by the child to its sdtdout winds up being routed through the pipe to the parent' stdin stream the effect is reminiscent of the way we tied together streams with the subprocess module in but this script is more low-level and less portable parallel system tools