call('python testexit_sys py'bye sys world pipe popen('python testexit_sys py'stdout=pipepipe communicate(( 'bye sys world\ \ 'nonepipe returncode the subprocess module works the same on unix-like platforms like cygwinbut unlike os popenthe exit status is not encodedand so it matches the windows result (note that shell=true is needed to run this as is on cygwin and unix-like platformsas we learned in on windows this argument is required only to run commands built into the shelllike dir)[ :\pp \system\exits]python from subprocess import popenpipecall pipe popen('python testexit_sys py'stdout=pipeshell=truepipe stdout read( 'bye sys world\npipe wait( call('python testexit_sys py'shell=truebye sys world process exit status and shared state nowto learn how to obtain the exit status from forked processeslet' write simple forking programthe script in example - forks child processes and prints child process exit statuses returned by os wait calls in the parent until "qis typed at the console example - pp \system\exits\testexit_fork py ""fork child processes to watch exit status with os waitfork works on unix and cygwin but not standard windows python notespawned threads share globalsbut each forked process has its own copy of them (forks share file descriptors)--exitstat is always the same here but will vary if for threads""import os exitstat def child()global exitstat exitstat + could os exit script here change this process' global exit status to parent' wait program exits