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.
如果有人知道该怎么做,请与我分享,谢谢!如何通过pid或处理程序将“Ctrl + Break”发送到子进程
发送过程中的信号,而不是钥匙。 – Keith
creationflags = subprocess.CREATE_NEW_PROCESS_GROUP应在调用子进程时添加。 – user478514