notice that the last test in the preceding code didn' attempt to read the command' output pipe if we dowe may have to run the target script in unbuffered mode with the - python command-line flag or change the script to flush its output manually with sys stdout flush otherwisethe text printed to the standard output stream might not be flushed from its buffer when os _exit is called in this case for immediate shutdown by defaultstandard output is fully buffered when connected to pipe like thisit' only line-buffered when connected to terminalpipe os popen('python testexit_os py'pipe read('pipe os popen('python - testexit_os py'pipe read('bye os world\nstreams not flushed on exit force unbuffered streams confusinglyyou can pass mode and buffering argument to specify line buffering in both os popen and subprocess popenbut this won' help here--arguments passed to these tools pertain to the calling process' input end of the pipenot to the spawned program' output streampipe os popen('python testexit_os py'' ' pipe read('line buffered only but my pipenot program'sfrom subprocess import popenpipe pipe popen('python testexit_os py'bufsize= stdout=pipepipe stdout read( 'for my pipe doesn' help reallybuffering mode arguments in these tools pertain to output the caller writes to command' standard input streamnot to output read from that command if requiredthe spawned script itself can also manually flush its output buffers periodically or before forced exits more on buffering when we discuss the potential for deadlocks later in this and again in and where we'll see how it applies to sockets since we brought up subprocessthoughlet' turn to its exit tools next exit status with subprocess the alternative subprocess module offers exit status in variety of waysas we saw in and ( none value in returncode indicates that the spawned program has not yet terminated) :\pp \system\exitspython from subprocess import popenpipecall pipe popen('python testexit_sys py'stdout=pipepipe stdout read( 'bye sys world\ \ parallel system tools