tryoutahere(finallyprint('cleanup'bye os world ditto shell command exit status codes both the sys and os exit calls we just met accept an argument that denotes the exit status code of the process (it' optional in the sys call but required by osafter exitthis code may be interrogated in shells and by programs that ran the script as child process on linuxfor examplewe ask for the status shell variable' value in order to fetch the last program' exit statusby conventiona nonzero status generally indicates that some sort of problem occurred[mark@linux]python testexit_sys py bye sys world [mark@linux]echo $status [mark@linux]python testexit_os py bye os world [mark@linux]echo $status in chain of command-line programsexit statuses could be checked along the way as simple form of cross-program communication we can also grab hold of the exit status of program run by another script for instanceas introduced in and when launching shell commandsexit status is provided asthe return value of an os system call the return value of the close method of an os popen object (for historical reasonsnone is returned if the exit status was which means no error occurreda variety of interfaces in the subprocess module ( the call function' return valuea popen object' returnvalue attribute and wait method resultin additionwhen running programs by forking processesthe exit status is available through the os wait and os waitpid calls in parent process exit status with os system and os popen let' look at the case of the shell commands first--the followingrun on linuxspawns example - and example - reads the output streams through pipes and fetches their exit status codes[mark@linux]python import os pipe os popen('python testexit_sys py' parallel system tools