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

    1. <legend id='N8TaU'><style id='N8TaU'><dir id='N8TaU'><q id='N8TaU'></q></dir></style></legend>

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

      1. <tfoot id='N8TaU'></tfoot>
        • <bdo id='N8TaU'></bdo><ul id='N8TaU'></ul>

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

        確定 python 子進(jìn)程分段是否錯(cuò)誤

        Determining if a python subprocess segmentation faults(確定 python 子進(jìn)程分段是否錯(cuò)誤)
        • <bdo id='RpI3g'></bdo><ul id='RpI3g'></ul>
          <i id='RpI3g'><tr id='RpI3g'><dt id='RpI3g'><q id='RpI3g'><span id='RpI3g'><b id='RpI3g'><form id='RpI3g'><ins id='RpI3g'></ins><ul id='RpI3g'></ul><sub id='RpI3g'></sub></form><legend id='RpI3g'></legend><bdo id='RpI3g'><pre id='RpI3g'><center id='RpI3g'></center></pre></bdo></b><th id='RpI3g'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='RpI3g'><tfoot id='RpI3g'></tfoot><dl id='RpI3g'><fieldset id='RpI3g'></fieldset></dl></div>

        • <legend id='RpI3g'><style id='RpI3g'><dir id='RpI3g'><q id='RpI3g'></q></dir></style></legend>

              <tbody id='RpI3g'></tbody>

              <tfoot id='RpI3g'></tfoot>

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

                1. 本文介紹了確定 python 子進(jìn)程分段是否錯(cuò)誤的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在編寫一個(gè)對學(xué)生程序進(jìn)行評分的程序,我相信您可以想象,它們有時(shí)會出現(xiàn)分段錯(cuò)誤.我遇到的問題是,當(dāng)學(xué)生編程分段錯(cuò)誤時(shí),沒有跡象表明發(fā)生了什么.

                  I am writing a program that grades student programs, and as I am sure you can imagine, they sometimes segmentation fault. The problem I am having is that when the student programs segmentation fault, there is no indication that is what happened.

                  proc = subprocess.Popen(student_command, 
                                          stdout=subprocess.PIPE, 
                                          stderr=subprocess.PIPE)
                  self.stdout, self.stderr = proc.communicate()
                  self.returncode = proc.returncode
                  

                  我從 subprocess 中提取 stderrstdout 和返回碼,但如果程序分段出錯(cuò),stderr 為空,stdout 為空,返回碼為-11.現(xiàn)在我可以查找 -11 退出代碼并假設(shè)如果這是返回代碼,則存在分段錯(cuò)誤,但也沒有什么可以阻止學(xué)生的代碼將 -11 作為返回代碼僅僅因?yàn)閷W(xué)生感覺想要返回-11.

                  I pick up the stderr, stdout, and the return code from the subprocess, but if the program segmentation faults, stderr is empty, stdout is empty, and the return code is -11. Now I could look for the -11 exit code and assume that if that is the return code there was a segmentation fault, but there is also nothing to prevent a student's code from having -11 as a return code just because the student felt like returning -11.

                  您如何判斷子進(jìn)程分段是否出錯(cuò),而不是僅僅感覺返回 -11?我不太關(guān)心 stderr 和 stdout 中的內(nèi)容,為此我看到了許多帖子,包括 this 處理拾取輸出,但我不太在意輸出,盡管獲得 "分段錯(cuò)誤"從 stderr 中取出字符串,但我真正需要的是一種明確說明子進(jìn)程發(fā)生了什么的方法.

                  How do you tell if a subprocess segmentation faults, as opposed to just feeling like returning -11? I don't really care all that much about what is in stderr and stdout, and to that end have seen a number of posts including this that deal with picking up the output, but I don't care all that much about the output, although it would be nice to get the "Segmentation Fault" string out of stderr, but what I really need is a way to definitively tell what happened to the subprocess.

                  推薦答案

                  事實(shí)上,在 UNIX 上,嘗試返回 -11 的進(jìn)程通常最終會返回一個(gè)正整數(shù).這是因?yàn)?wait 系列函數(shù)的返回狀態(tài)實(shí)際上是一組位域,其中一個(gè)域用于結(jié)束進(jìn)程的信號,另一個(gè)域用于返回值.Python 從這些位域解碼 wait 返回值.

                  Well, in fact, on UNIX, a process that attempts to return -11 will usually end up returning a positive integer instead. This is because the return status from the wait series of functions is actually a set of bitfields, with a field for the signal that ended the process and a separate field for the return value. Python decodes the wait return value from these bitfields.

                  在大多數(shù)系統(tǒng)上,這些字段是無符號的,大小為 8 位,因此您可能會看到如下內(nèi)容:

                  On most systems, these fields are unsigned and 8 bits in size, so you will probably see something like this:

                  >>> import subprocess
                  >>> subprocess.Popen(['python','-c','import os; os.kill(os.getpid(),11)']).wait()
                  -11
                  >>> subprocess.Popen(['python','-c','exit(-11)']).wait()
                  245
                  

                  在前一種情況下,進(jìn)程segfaults"(通過使用 SIGSEGV 殺死自己),因此 wait 返回 -11.在后一種情況下,進(jìn)程以 -11 的返回碼退出,結(jié)果 wait 值為 245 (256-11).因此,您可以放心,來自 wait 的任何負(fù)返回值都必須代表致命信號,而不是正常返回.但請注意,這些進(jìn)程可能會殺死自己以偽造致命錯(cuò)誤.

                  In the former case, the process "segfaults" (by killing itself with SIGSEGV), and so wait returns -11. In the latter case, the process exits with a return code of -11, and the resulting wait value is 245 (256-11). You can therefore rest assured that any negative return value from wait must represent a fatal signal, as opposed to a normal return. Note, though, that processes may kill themselves to fake a fatal error.

                  這篇關(guān)于確定 python 子進(jìn)程分段是否錯(cuò)誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進(jìn)度躍升至 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 刻度標(biāo)簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動時(shí),yaxis 刻度標(biāo)簽應(yīng)該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時(shí)顯示進(jìn)度條?)

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

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

                            主站蜘蛛池模板: 亚洲经典一区 | 国产成人精品午夜 | 综合网视频| 午夜免费福利电影 | 国产91丝袜在线播放 | 日本超碰 | 求个av网址| 欧美成人免费在线 | 国产探花在线精品一区二区 | 日韩成人免费在线视频 | 精品成人av| 日韩免费一区二区 | 国产精品99999 | 日韩久久精品电影 | 精品乱码一区二区三四区视频 | 成人福利在线观看 | 精品在线一区 | 成人免费大片黄在线播放 | 国内精品久久久久久 | 色婷婷av777 av免费网站在线 | aaaa网站 | 欧美精品一区在线 | 91视频三区| 国产亚洲精品久久午夜玫瑰园 | 欧美一级片在线看 | 精品成人佐山爱一区二区 | 久久精品亚洲一区 | 欧美精品一区三区 | 国产精品久久久久无码av | 黄色三级毛片 | 日韩精品一二三区 | 国产精品一区二区日韩 | 久久青视频 | 91极品视频 | 久久免费视频观看 | 东京久久| 久久久久久久久久影视 | 99re6在线视频 | 欧美一级在线 | 欧美日韩中文字幕 | av特级毛片|