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