久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

      <tfoot id='wCFNt'></tfoot>
      1. 來自信號處理程序的 sys.exit() 上的 Python 核心轉儲

        Python core dump on sys.exit() from signal handler(來自信號處理程序的 sys.exit() 上的 Python 核心轉儲)

        1. <tfoot id='4SLny'></tfoot>
          <i id='4SLny'><tr id='4SLny'><dt id='4SLny'><q id='4SLny'><span id='4SLny'><b id='4SLny'><form id='4SLny'><ins id='4SLny'></ins><ul id='4SLny'></ul><sub id='4SLny'></sub></form><legend id='4SLny'></legend><bdo id='4SLny'><pre id='4SLny'><center id='4SLny'></center></pre></bdo></b><th id='4SLny'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4SLny'><tfoot id='4SLny'></tfoot><dl id='4SLny'><fieldset id='4SLny'></fieldset></dl></div>

                <tbody id='4SLny'></tbody>
              • <bdo id='4SLny'></bdo><ul id='4SLny'></ul>
              • <legend id='4SLny'><style id='4SLny'><dir id='4SLny'><q id='4SLny'></q></dir></style></legend>

                <small id='4SLny'></small><noframes id='4SLny'>

                  本文介紹了來自信號處理程序的 sys.exit() 上的 Python 核心轉儲的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我看到一個看似無害的程序的 python 核心轉儲.我編寫了以下代碼來演示我的問題:

                  I am seeing python core dump for a seemingly harmless program. I have written following piece of code to demonstrate my problem:

                  proc = None
                  
                  def __signalHandler(signum, frame):
                     print "In __signalHandler"
                  
                     if proc is not None:
                        print "Send signal to BG proc"
                        os.killpg(os.getpgid(proc.pid), signal.SIGINT)
                  
                        print "Wait for it to finish"
                        proc.communicate()
                  
                     print "sys exit"
                     sys.exit(130)
                  
                  signal.signal(signal.SIGINT, __signalHandler)
                  
                  # Start the process
                  proc = subprocess.Popen(["a.out"],
                                          stdout=subprocess.PIPE,
                                          stderr=subprocess.PIPE,
                                          preexec_fn=os.setsid)
                  
                  while proc.poll() is None:
                     try:
                        print proc.stdout.readline()
                     except:
                        print "Exception caught"
                  
                  print "Done!"
                  

                  a.out 是打印語句并循環休眠的可執行文件:

                  a.out is a executable that prints statement and sleeps in a loop:

                  int main(int argc, char* argv[])
                  {
                     for (int i = 0; i < 100; i++)
                     {
                        printf("Sleeping...
                  ");
                        std::cout.flush();
                        usleep(500000);
                     }
                  
                     return 0;
                  }
                  

                  以下是我運行 python 代碼時得到的輸出(我運行 python 程序,然后按 Ctrl-C 以便調用信號處理程序):

                  Following is the output I get when I run the python code (I run the python program and then press Ctrl-C so that the signal handler gets invoked):

                  $ python sample.py
                  Sleeping...
                  Sleeping...
                  Sleeping...
                  ^CIn __signalHandler
                  Send signal to BG proc
                  Wait for it to finish
                  sys exit
                  Segmentation fault (core dumped)
                  

                  有人知道為什么 python 核心轉儲嗎?有沒有什么辦法解決這一問題?我的猜測是 sys.exit() 拋出的異常在某種程度上導致了問題.os._exit() 沒有同樣的問題.但是,我正在嘗試找出這種行為背后的確切原因.

                  Does anyone have a clue why python core dumps? Is there any way to fix this? My guess is that the exception thrown from sys.exit() is somehow causing a problem. os._exit() doesnt have the same issue. However, I am trying to find out the exact reason behind this behaviour.

                  不管怎樣,我使用的是 Python 2.7.3

                  For what it's worth, I am using Python 2.7.3

                  推薦答案

                  這個版本有效:中斷頂層程序正確打印sys exit",子進程的輸出逐行打印.

                  This version works: interrupting the top-level program correctly prints "sys exit", and output of the subprocess is printed line by line.

                  import os, signal, subprocess, sys
                  
                  proc = None
                  
                  def __signalHandler(signum, frame):
                     print "In __signalHandler"
                  
                     if proc is not None:
                        print "Send signal to BG proc"
                        os.killpg(os.getpgid(proc.pid), signal.SIGINT)
                  
                        print "Wait for it to finish"
                        proc.communicate()
                  
                     print "sys exit"
                     sys.exit(130)
                  
                  signal.signal(signal.SIGINT, __signalHandler)
                  
                  # Start the process
                  proc = subprocess.Popen('ping -c3 8.8.8.8'.split(),
                                          stdout=subprocess.PIPE,
                                          stderr=subprocess.PIPE,
                                          preexec_fn=os.setsid)
                  
                  while proc.poll() is None:
                     try:
                        print proc.stdout.readline(),
                     except Exception as exc:
                        print 'Exception caught: {}'.format(exc)
                  
                  print "Done!"
                  

                  輸出

                  $ python ./sub5.py 
                  
                  PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
                  64 bytes from 8.8.8.8: icmp_seq=1 ttl=43 time=48.0 ms
                  64 bytes from 8.8.8.8: icmp_seq=2 ttl=43 time=48.3 ms
                  ^CIn __signalHandler
                  Send signal to BG proc
                  Wait for it to finish
                  sys exit
                  
                  $ echo $?
                  130
                  

                  這篇關于來自信號處理程序的 sys.exit() 上的 Python 核心轉儲的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                • <i id='eAe6j'><tr id='eAe6j'><dt id='eAe6j'><q id='eAe6j'><span id='eAe6j'><b id='eAe6j'><form id='eAe6j'><ins id='eAe6j'></ins><ul id='eAe6j'></ul><sub id='eAe6j'></sub></form><legend id='eAe6j'></legend><bdo id='eAe6j'><pre id='eAe6j'><center id='eAe6j'></center></pre></bdo></b><th id='eAe6j'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='eAe6j'><tfoot id='eAe6j'></tfoot><dl id='eAe6j'><fieldset id='eAe6j'></fieldset></dl></div>

                  <tfoot id='eAe6j'></tfoot>
                    <tbody id='eAe6j'></tbody>

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

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

                            主站蜘蛛池模板: 日韩福利视频 | 天天插天天干 | 日本不卡一二三 | 国产精品福利视频 | 国产精品毛片一区二区在线看 | 国产一区二区在线播放 | 午夜激情免费 | 亚洲国产一区二区三区 | 亚洲自拍偷拍免费视频 | 在线观看成人小视频 | 日韩一区二区久久 | 91免费版在线观看 | 久色激情 | 人人看人人爽 | 色综合99| 久久国产一区二区 | 欧美日韩亚洲国产 | 国产精品视频播放 | 亚洲精品久久久蜜桃 | 在线看成人av | 中文字幕在线观看第一页 | 一级毛片视频 | 亚洲在线电影 | 精品日韩电影 | 精品一二区 | 久久久www成人免费无遮挡大片 | 国产精品美女久久久久久免费 | 99视频免费播放 | 我要看一级片 | 久久国产精品视频 | 天堂精品 | 91偷拍精品一区二区三区 | 一区二区三区四区电影视频在线观看 | 亚洲a毛片 | 蜜桃av一区二区三区 | 一区视频 | 国产精品视频免费观看 | 日韩精品一区二区在线 | 91国产精品在线 | 日一区二区 | 欧美成人激情 |