我在 GTK 窗口中使用 VTE 模块来运行并显示 bash 脚本的结果。
adresse = self.champ.get_text()
pid = self.v.fork_command(None, ['/bin/bash', "./pluzz.sh", adresse])
if pid == None: #pseudocode
print "Finish"
如果有 time.sleep 或循环,子进程将阻塞(不运行)。我能怎么做 ?谢谢
编辑:试过这个:
def check_pid(pid):
""" Check For the existence of a unix pid. """
try:
os.kill(pid, 0)
except OSError:
return False
else:
return True
问题是返回一次为真,如果我写一个循环,bash 脚本就会阻塞。