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

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

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

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

      <tfoot id='Tmqm5'></tfoot>

        捕獲“分段錯誤"崩潰子進程的消息:調用com

        Capture quot;Segmentation faultquot; message for a crashed subprocess: no out and err after a call to communicate()(捕獲“分段錯誤崩潰子進程的消息:調用communication() 后沒有輸出和錯誤) - IT屋-程序員軟件開發技術
          <bdo id='sBmHE'></bdo><ul id='sBmHE'></ul>

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

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

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

                1. 本文介紹了捕獲“分段錯誤"崩潰子進程的消息:調用communication() 后沒有輸出和錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在使用 subprocess 模塊獲取崩潰程序的輸出時遇到問題.我正在使用 python2.7 和 subprocess 調用帶有奇怪參數的程序以獲得一些段錯誤為了調用程序,我使用以下代碼:

                  I have problems using the subprocess module to obtain the output of crashed programs. I'm using python2.7 and subprocess to call a program with strange arguments in order to get some segfaults In order to call the program, I use the following code:

                  proc = (subprocess.Popen(called,
                                           stdout=subprocess.PIPE,
                                           stderr=subprocess.PIPE))
                  out,err=proc.communicate()
                  print out,err
                  

                  被調用的是一個包含程序名稱和參數的列表(一個包含隨機字節的字符串,除了子進程根本不喜歡的 NULL 字節)

                  called is a list containing the name of the program and the argument (a string containing random bytes except the NULL byte which subprocess doesn't like at all)

                  當程序沒有崩潰時,代碼會運行并向我顯示 stdout 和 stderr,但是當它確實崩潰時,out 和 err 為空,而不是顯示著名的分段錯誤".

                  The code behave and show me the stdout and stderr when the program doesn't crash, but when it does crash, out and err are empty instead of showing the famous "Segmentation fault".

                  我希望找到一種方法,即使程序崩潰也會出錯.

                  I wish to find a way to obtain out and err even when the program crash.

                  我也試過 check_output/call/check_call 方法

                  I also tried the check_output / call / check_call methods

                  一些附加信息:

                  • 我在 python 虛擬環境中的 Archlinux 64 位上運行這個腳本(這里不應該是重要的東西,但你永遠不知道:p)

                  • I'm running this script on an Archlinux 64 bits in a python virtual environment (shouldn't be something important here, but you never know :p)

                  段錯誤發生在我嘗試運行的 C 程序中,是緩沖區溢出的結果

                  The segfault happens in the C program I'm trying to run and is a consequence of a buffer overflow

                  問題是當segfault發生時,我無法得到子進程發生了什么的輸出

                  The problem is that when the segfault occurs, I can't get the output of what happened with subprocess

                  我得到正確的返回碼:-11 (SIGSEGV)

                  I get the returncode right: -11 (SIGSEGV)

                  使用python我得到:

                  Using python i get:

                    ./dumb2 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 
                    ('Exit code was:', -11) 
                    ('Output was:', '') 
                    ('Errors were:', '')
                  

                2. 在 python 之外我得到:

                3. While outside python I get:

                   ./dumb2 $(perl -e "print 'A'x50")  
                   BEGINNING OF PROGRAM 
                   AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                   END OF THE PROGRAM
                   Segmentation fault (core dumped)
                  

                4. shell的返回值是一樣的:echo $?返回 139 所以 -11 ($? & 128)

                5. The return value of the shell is the same: echo $? returns 139 so -11 ($? & 128)

                  推薦答案

                  回到這里:它就像 python3 的 subprocess 的魅力,如果你在 linux 上,有一個名為 subprocess32 的向后移植到 python2代碼> 效果很好

                  Came back here: it works like a charm with subprocess from python3 and if you are on linux, there is a backport to python2 called subprocess32 which does work quite well

                  較舊的解決方案:我使用了 pexpect,它可以工作

                  Older solution: I used pexpect and it works

                  def cmd_line_call(name, args):
                      child = pexpect.spawn(name, args)
                      # Wait for the end of the output
                      child.expect(pexpect.EOF) 
                      out = child.before # we get all the data before the EOF (stderr and stdout)
                      child.close() # that will set the return code for us
                      # signalstatus and existstatus read as the same (for my purpose only)
                      if child.exitstatus is None:
                          returncode = child.signalstatus
                      else:
                          returncode = child.exitstatus
                      return (out, returncode)
                      
                  

                  PS:慢一點(因為它會產生一個偽 tty)

                  PS: a little slower (because it spawns a pseudo tty)

                  這篇關于捕獲“分段錯誤"崩潰子進程的消息:調用communication() 后沒有輸出和錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  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時顯示進度條?)
                    <bdo id='whX2p'></bdo><ul id='whX2p'></ul>
                      <tbody id='whX2p'></tbody>

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

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

                          • 主站蜘蛛池模板: 久久99精品久久久久蜜桃tv | 国产高清精品网站 | 一级黄色片在线免费观看 | 99国内精品久久久久久久 | 欧美一级大片免费观看 | 精品国产乱码一区二区三区a | 中文字幕精品视频 | 精品av| 四色成人av永久网址 | 成人精品鲁一区一区二区 | 天天干夜夜操 | 在线欧美| www操操| 狠狠操你 | 国产综合视频 | 欧美精品91| 久艹av | 欧美日日 | 美国十次成人欧美色导视频 | 亚洲不卡 | 日本精品国产 | 在线视频91 | 综合色播 | 欧美精品久久久久久久久老牛影院 | 欧美色综合天天久久综合精品 | 国产免费观看一区 | 福利视频一区二区 | 亚洲欧美日韩国产综合 | 日日日干干干 | 亚洲高清一区二区三区 | 国产成人精品免高潮在线观看 | 黄色国产视频 | 成人免费日韩 | 免费观看一级黄色录像 | 亚洲h色| 婷婷五月色综合 | 一区二区三区小视频 | 在线观看免费观看在线91 | 成人久久久| 日日干日日 | 久久久久国产精品人 |