简体   繁体   English

Stty在使用Python子进程时变得疯狂

[英]Stty getting insane on using Python subprocess

I am facing a weird problem. 我面临一个奇怪的问题。 Every time I call a particular command cmd via subprocess.Popen(cmd).wait() , the stty gets bad (does not echo my further commands on the shell, newline does not work, etc.) when the command is over. 每次我通过subprocess.Popen(cmd).wait()调用特定命令cmdsubprocess.Popen(cmd).wait() ,stty都会变坏(不会在外壳上回显我的其他命令,换行符等)。 I have to run stty sane to get the stty fine again. 我必须使stty sane ,才能再次使sty变好。 What could be the reason for this? 这可能是什么原因?

Update The command I am running is starting the elasticsearch process. 更新我正在运行的命令正在启动Elasticsearch进程。 The command launches the process in the background. 该命令在后台启动该过程。

It's possible that the command you're running is emitting some escape sequences into your terminal that are changing its mode or other settings. 您正在运行的命令可能会向您的终端发出一些转义序列,从而改变其模式或其他设置。 Programs that need the full terminal capability do that (eg text based editors). 需要完全终端功能的程序可以做到这一点(例如,基于文本的编辑器)。

Capturing the standard output of the program you're executing and preventing it from going to the screen might help. 捕获正在执行的程序的标准输出并阻止其进入屏幕可能会有所帮助。 Have you tried that? 你有尝试过吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM