【发布时间】:2011-11-03 10:22:57
【问题描述】:
import subprocess
proc = subprocess.Popen(['c:\windows\system32\ping.exe','127.0.0.1', '-t'],stdout=subprocess.PIPE)
while True:
line = proc.stdout.readline()
print "ping result:", line.rstrip()
#sendkey("Ctrl+Break", proc) # i need this here, this is not for terminate the process but to print a statistics result for the ping result.
如果有人知道怎么做,请与我分享,谢谢!
【问题讨论】:
-
向进程发送信号,而不是密钥。
-
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP 应在调用子流程时添加。