Python's built-in subprocess.Popen object

For details, see: https://docs.python.org/3/library/subprocess.html

Roughly speaking, a process can be generated corresponding to the input command, and the process instance has the following methods built-in.

 |  communicate(self, input=None, timeout=None)
 |      Interact with process: Send data to stdin.  Read data from
 |      stdout and stderr, until end-of-file is reached.  Wait for
 |      process to terminate.  The optional input argument should be
 |      bytes to be sent to the child process, or None, if no data
 |      should be sent to the child.
 |      
 |      communicate() returns a tuple (stdout, stderr).
 |  
 |  kill = terminate(self)
 |  
 |  poll(self)
 |  
 |  send_signal(self, sig)
 |      Send a signal to the process.
 |  
 |  terminate(self)
 |      Terminates the process.
 |  
 |  wait(self, timeout=None, endtime=None)
 |      Wait for child process to terminate.  Returns returncode
 |      attribute.

In the Windows system, kill is an alias for the terminate method. In the Linux system, kill sends a SIGKILL signal to the process, and the terminate method sends a SIGTERM signal to the process.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325002935&siteId=291194637