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

      2. <tfoot id='fUXkQ'></tfoot>
      3. python守护进程中的子进程杀死

        时间:2023-09-03
          <tbody id='3Z8Hs'></tbody>
          • <legend id='3Z8Hs'><style id='3Z8Hs'><dir id='3Z8Hs'><q id='3Z8Hs'></q></dir></style></legend>

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

                  <bdo id='3Z8Hs'></bdo><ul id='3Z8Hs'></ul>

                  <small id='3Z8Hs'></small><noframes id='3Z8Hs'>

                  <tfoot id='3Z8Hs'></tfoot>

                  本文介绍了python守护进程中的子进程杀死的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 python 中有运行外部程序的 damon:

                  I have damon in python which runs external program:

                  subprocess.call(["java", "-jar", "start.jar"])
                  

                  当我杀死守护进程时,子进程(java)仍在运行

                  when I kill daemon, the child process (java) is still running

                  我怎样才能让子进程也被杀死?

                  how can I make so that child process is also killed ?

                  推荐答案

                  使用 subprocess.Popen() 而不是 subprocess.call().例如:

                  Use subprocess.Popen() instead of subprocess.call(). For example:

                  import subprocess
                  my_process = subprocess.Popen(['ls', '-l'])
                  

                  终止孩子:

                  my_process.kill()
                  

                  要捕获终止信号,您可以这样:

                  To capture the kill signal, you could so something like this:

                  import signal
                  import sys
                  def signal_handler(signal, frame):
                      sys.exit(0)
                  signal.signal(signal.SIGINT, signal_handler)
                  

                  这篇关于python守护进程中的子进程杀死的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python 子进程 Popen 与 Pyinstaller 下一篇:如何使用 Python (Windows Vista) 检索列表中文件的标签?

                  相关文章

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

                    <legend id='ol78r'><style id='ol78r'><dir id='ol78r'><q id='ol78r'></q></dir></style></legend>

                      <tfoot id='ol78r'></tfoot>