is there a way to start/stop linux processes with python?

后端 未结 6 913
你的背包
你的背包 2021-01-05 02:31

I want to be able to start a process and then be able to kill it afterwards

6条回答
  •  自闭症患者
    2021-01-05 02:48

    A simple function that uses subprocess module:

    def CMD(cmd) :
        p = subprocess.Popen(cmd, shell=True,
                             stdin=subprocess.PIPE,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE,
                             close_fds=False)
        return (p.stdin, p.stdout, p.stderr)
    

提交回复
热议问题