1

我对 Python 很陌生。这是我的代码:

def start(self, widget):
    s = subprocess.Popen('myprocess')

def stop(self, widget):
           #what to put here?

我在 Ubuntu 上。在第一个函数中,我启动了一个需要 CTRL+C 来终止的进程。我必须在停止函数中输入哪些指令来终止进程?

非常感谢您提前。

4

1 回答 1

0

I simply solved with a global variable s. So my code become:

 s = None

 def start(self, widget):
       global s
       s = subprocess.Popen('myprocess')

 def stop(self, widget):
       s.kill()
于 2013-05-24T09:15:02.110 回答