zoukankan      html  css  js  c++  java
  • Python内置的subprocess.Popen对象

    具体内容参见:https://docs.python.org/3/library/subprocess.html

    大概来说,就是可以对应输入的命令产生一个进程,该进程实例内置如下方法。

     |  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.

    在windows系统中,kill是terminate方法的别名,在linux系统中,kill向进程发送SIGKILL信号,terminate方法向进程发送SIGTERM信号。

  • 相关阅读:
    python 模拟(简易)音乐播放器
    Python中的多态如何理解?(转)
    mysql踩得坑
    python简单模拟博客园系统
    04 信号量
    02 事件
    01 管道
    32 管道 事件 信号量 进程池 线程的创建
    02 验证进程之间是空间隔离的
    01 进程的其他方法
  • 原文地址:https://www.cnblogs.com/lyg-blog/p/8966978.html
Copyright © 2011-2022 走看看