• <small id='6GPLy'></small><noframes id='6GPLy'>

    • <bdo id='6GPLy'></bdo><ul id='6GPLy'></ul>
    <legend id='6GPLy'><style id='6GPLy'><dir id='6GPLy'><q id='6GPLy'></q></dir></style></legend>

    <tfoot id='6GPLy'></tfoot>
  • <i id='6GPLy'><tr id='6GPLy'><dt id='6GPLy'><q id='6GPLy'><span id='6GPLy'><b id='6GPLy'><form id='6GPLy'><ins id='6GPLy'></ins><ul id='6GPLy'></ul><sub id='6GPLy'></sub></form><legend id='6GPLy'></legend><bdo id='6GPLy'><pre id='6GPLy'><center id='6GPLy'></center></pre></bdo></b><th id='6GPLy'></th></span></q></dt></tr></i><div id='6GPLy'><tfoot id='6GPLy'></tfoot><dl id='6GPLy'><fieldset id='6GPLy'></fieldset></dl></div>
      1. 终止子进程后终端文本变得不可见

        时间:2023-09-02

          <tfoot id='uAQwt'></tfoot>
            <bdo id='uAQwt'></bdo><ul id='uAQwt'></ul>
              <tbody id='uAQwt'></tbody>

            <small id='uAQwt'></small><noframes id='uAQwt'>

                • <i id='uAQwt'><tr id='uAQwt'><dt id='uAQwt'><q id='uAQwt'><span id='uAQwt'><b id='uAQwt'><form id='uAQwt'><ins id='uAQwt'></ins><ul id='uAQwt'></ul><sub id='uAQwt'></sub></form><legend id='uAQwt'></legend><bdo id='uAQwt'><pre id='uAQwt'><center id='uAQwt'></center></pre></bdo></b><th id='uAQwt'></th></span></q></dt></tr></i><div id='uAQwt'><tfoot id='uAQwt'></tfoot><dl id='uAQwt'><fieldset id='uAQwt'></fieldset></dl></div>
                  <legend id='uAQwt'><style id='uAQwt'><dir id='uAQwt'><q id='uAQwt'></q></dir></style></legend>
                • 本文介绍了终止子进程后终端文本变得不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在终止一个 ffmpeg 子进程后,终端变得一团糟——输入的字符是不可见的!输入仍然有效,可以执行命令,但键盘输入不会回显到终端.

                  After terminating an ffmpeg subprocess, the terminal gets messed up - typed characters are invisible! The input still works in that commands can be executed, but keyboard input is not echoed to the terminal.

                  发出 shell 命令 reset 使一切恢复正常(或 ipython 中的 !reset),因此解决此问题的方法是调用 os.system('reset') 在脚本中.

                  Issuing shell command reset puts everything back to normal (or !reset from within ipython), so a workaround the issue is calling os.system('reset') inside the script.

                  我尝试过的其他事情:import curses;curses.initscr() 在产生子进程之前和 curses.endwin() 在终止之后,这有点工作但破坏了其他东西.另一个可能相关的问题是,在生成子进程后,交互式终端变得迟钝,有时无法捕获键入的字符.

                  Other things I've tried: import curses; curses.initscr() before spawning the subprocess and curses.endwin() after termination, which worked somewhat but broke other stuff. Another possibly related issue is that after spawning the child process, the interactive terminal becomes laggy and sometimes fails to capture typed characters.

                  生成进程的代码如下所示:

                  The code to spawn the process looks like:

                  with open('/tmp/stdout.log', 'w') as o:
                      with open('/tmp/stderr.log', 'w') as e:
                          proc = subprocess.Popen([args], stdout=o, stderr=e)
                  

                  然后停止它:

                  proc.terminate()
                  proc.communicate()
                  

                  这里可能出了什么问题?

                  What could be going wrong here?

                  推荐答案

                  更改脚本,使 proc.terminate() 不被使用.您可以使用

                  Change the script so that proc.terminate() is not used. You can stop an ffmpeg subprocess more politely with

                    proc.send_signal(signal.SIGINT)
                    proc.wait()
                  

                  这让 ffmpeg 有机会编写恢复终端所需的任何转义序列.

                  This allows ffmpeg the chance to write whatever escape sequences it needs to restore the terminal.

                  edit: 稍后发现 - 使 ffmpegPopen 一起表现更好的另一个技巧是为其提供一个 subprocess.PIPEopen(os.devnull)stdin 句柄中.否则,它似乎会尝试从父级的标准输入获取输入,这可能会导致奇怪的终端行为.正在运行的 ffmpeg 进程正在监听?"和标准输入上的q"输入.

                  edit: discovered later- another tip to make ffmpeg behave better with Popen is to provide it a subprocess.PIPE or open(os.devnull) in the stdin handle. Otherwise, it seems to try to get input from the parent's stdin which can cause weird terminal behaviour. A running ffmpeg process is listening for '?' and 'q' input on stdin.

                  这篇关于终止子进程后终端文本变得不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Python 中使用子进程从进程中无缓冲读取 下一篇:OSError:[Errno 22] 子进程中的参数无效

                  相关文章

                  1. <legend id='aV5Do'><style id='aV5Do'><dir id='aV5Do'><q id='aV5Do'></q></dir></style></legend>
                    • <bdo id='aV5Do'></bdo><ul id='aV5Do'></ul>

                    <small id='aV5Do'></small><noframes id='aV5Do'>

                    <tfoot id='aV5Do'></tfoot>

                      <i id='aV5Do'><tr id='aV5Do'><dt id='aV5Do'><q id='aV5Do'><span id='aV5Do'><b id='aV5Do'><form id='aV5Do'><ins id='aV5Do'></ins><ul id='aV5Do'></ul><sub id='aV5Do'></sub></form><legend id='aV5Do'></legend><bdo id='aV5Do'><pre id='aV5Do'><center id='aV5Do'></center></pre></bdo></b><th id='aV5Do'></th></span></q></dt></tr></i><div id='aV5Do'><tfoot id='aV5Do'></tfoot><dl id='aV5Do'><fieldset id='aV5Do'></fieldset></dl></div>