Starting with the python2.4 version, you can use the Subprocess module to generate child processes and connect to the child process's standard input/output/error, as well as to get the return value of the child process.Subprocess is intended to
36.16.commands-utilities for runningcommandsDeprecated since version 2.6:the commands module has been removed in Python 3. Use the subprocess module instead.The commands module contains wrapper functions for Os.popen () which take a system command
s under Linux we should try to avoid using system. Now let's look at a simple introduction to the system () function under Linux:
#include
int system (Const char* command)
The system () function calls/bin/sh to execute the specified command of a
1. Fork + Exec
Fork is used to create a child process. When a program calls the fork function, the system prepares the preceding three segments for a new process. First, the system allows the new process and the old process to use the same code
1. Fork + execFork is used to create a child process. When a program calls the fork function, the system prepares the previous three segments for a new process, first, the system allows the new process to use the same code snippet as the old process,
Directory
Directory preface software Environment Knowledge Subprocess Popen Constructor constructor Class Popen parameter args calling program call shell instruction Stdinstdoutstderr real-time fetch subroutine output one time get all output of
Original article address:Subprocess in Python
Author:Grinding From: http://li2z.cn/2010/04/14/python_subprocess/
Just like python built-in functions, the content is all from the official Python documentation, but it is not a simple translation.
Python provides multiple modules for creating sub-processes. I prefer to use the subprocess module because the python manual contains the following:
This module intends to replace several other, older modules and functions, such as: OS. System, OS.
1.2. Popen ObjectsAn instance of the Popen class has the following methods:1. Popen.poll ()Checks whether the child process has ended, sets and returns the return code value.2. Popen.wait ()Waits for the child process to end, sets and returns the
ZZ from:http://www.cnblogs.com/oubo/archive/2011/10/10/2394593.html
Python subprocess Create child processes
Python provides multiple modules for creating child processes, and I am more accustomed to using the subprocess module because there is
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.