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

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

        <legend id='mnM4Q'><style id='mnM4Q'><dir id='mnM4Q'><q id='mnM4Q'></q></dir></style></legend>
          <bdo id='mnM4Q'></bdo><ul id='mnM4Q'></ul>
      1. <tfoot id='mnM4Q'></tfoot>
      2. 如何使用 shell = true 使用 Python subprocess.Popen() 将 SIGINT 传递给子

        时间:2023-07-21
        1. <legend id='870T5'><style id='870T5'><dir id='870T5'><q id='870T5'></q></dir></style></legend>

            • <small id='870T5'></small><noframes id='870T5'>

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

                  本文介绍了如何使用 shell = true 使用 Python subprocess.Popen() 将 SIGINT 传递给子进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我目前正在尝试为 GDB 编写 (Python 2.7.3) 一种包装器,这将允许我从脚本输入动态切换到与 GDB 的交互式通信.

                  I am currently trying to write (Python 2.7.3) kind of a wrapper for GDB, which will allow me to dynamically switch from scripted input to interactive communication with GDB.

                  到目前为止我使用

                  self.process = subprocess.Popen(["gdb vuln"], stdin = subprocess.PIPE,  shell = True)
                  

                  在我的脚本中启动 gdb.(vuln 是我要检查的二进制文件)

                  to start gdb within my script. (vuln is the binary I want to examine)

                  由于 gdb 的一个关键特性是暂停附加进程的执行并允许用户在接收到 SIGINT (STRG+C) 时检查寄存器和内存,因此我确实需要一些方法来将 SIGINT 信号传递给它.

                  Since a key feature of gdb is to pause the execution of the attached process and allow the user to inspect registers and memory on receiving SIGINT (STRG+C) I do need some way to pass a SIGINT signal to it.

                  没有

                  self.process.send_signal(signal.SIGINT)
                  

                  也没有

                  os.kill(self.process.pid, signal.SIGINT)
                  

                  os.killpg(self.process.pid, signal.SIGINT)
                  

                  为我工作.

                  当我使用这些功能之一时,没有响应.我想这个问题是由使用 shell=True 引起的.但是,在这一点上,我真的没有想法.这次即使是我的老朋友 Google 也无法真正帮助我,所以也许你可以帮助我.提前致谢.

                  When I use one of these functions there is no response. I suppose this problem arises from the use of shell=True. However, at this point I am really out of ideas. Even my old friend Google couldn't really help me out this time, so maybe you can help me. Thank's in advance.

                  干杯,迈克

                  推荐答案

                  这对我有用:

                  import signal
                  import subprocess
                  
                  try:
                      p = subprocess.Popen(...)
                      p.wait()
                  except KeyboardInterrupt:
                      p.send_signal(signal.SIGINT)
                      p.wait()
                  

                  这篇关于如何使用 shell = true 使用 Python subprocess.Popen() 将 SIGINT 传递给子进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:subprocess.Popen 简单代码不允许我执行 cd (更改目录) 下一篇:使用 subprocess.Popen 的 Python 内存分配错误

                  相关文章

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

                    <bdo id='Rc5Zs'></bdo><ul id='Rc5Zs'></ul>

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