如何发送“Ctrl”Break通过 pid 或 handler 到子进程
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.
如果有人知道怎么做,请分享给我,谢谢!
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.
If someone know how to do it, please share with me, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
视窗?试试这个:
如果你的意思是信号中断(
kill -2
)Windows? Try this:
If you meant a signal interrupt (
kill -2
)Ctrl+Break 键是 SIGBREAK 信号。
在Linux下,您可以使用
kill
命令发送此信号,在Windows上,这略有不同。您可以使用 SendSignal 工具。The Ctrl+Break keys is a SIGBREAK signal.
Under linux, you can send this signal with
kill
command, on Windows, this is slightly different. You can use the SendSignal tool.