terminate(terminates the subprocess by sending it sigterm signal on unix or calling the win api terminateprocess function on windows wait(waits for to terminate and returns the return code pid process id of the child process returncode numeric return code of the process if nonethe process has not terminated yet if negativeit indicates the process was terminated by signal (unixp stdinp stdoutp stderr these three attributes are set to open file objects whenever the corresponding / stream is opened as pipe (for examplesetting the stdout argument in popen(to pipethese file objects are provided so that the pipe can be connected to other subprocesses these attributes are set to none if pipes are not in use examples execute basic system command like os system(ret subprocess call("ls - "shell=truesilently execute basic system command ret subprocess call("rm - java",shell=truestdout=open("/dev/null")execute system commandbut capture the output subprocess popen("ls - "shell=truestdout=subprocess pipeout stdout read(execute commandbut send input and receive output subprocess popen("wc"shell=truestdin=subprocess pipestdout=subprocess pipestderr=subprocess pipeouterr communicate(ssend string to the process create two subprocesses and link them together via pipe subprocess popen("ls - "shell=truestdout=subprocess pipep subprocess popen("wc",shell=truestdin= stdoutstdout=subprocess pipeout stdout read(notes as general ruleit is better to supply the command line as list of strings instead of single string with shell command (for example['wc','filename'instead of 'wc filename'on many systemsit is common for filenames to include funny characters and spaces (for examplethe "documents and settingsfolder on windowsif you stick to supplying command arguments as listeverything will work normally if you try to form shell commandyou will have to take additional steps to make sure special characters and spaces are properly escaped lib fl ff