Incorrect exit status of an already waited process in subprocess.Popen
還沒有人認領這個 Issue。
評估
這個 Issue 還沒有評估資料。
描述
Bug report
If a process run by subprocess.Popen and its exit status is obtained by os.wait() or os.waitpid(), then calling the wait() method on the Popen object always returns zero.
Example:
import os
import subprocess
proc = subprocess.Popen(["false"]) # could be any process with non-zero exit status
pid, status = os.wait()
print("status from os.wait()", status) # prints non-zero exit status correctly
print("status from proc.wait()", proc.wait()) # prints zero exit status incorrectly
The root cause of the problem is that the child has been already wait()ed, so the Popen object has no chance to obtain the exit code as the process no longer exists. It calls waitpid() here but it ignores ECHILD and defaults the status to zero.
Your environment
- CPython versions tested on:
Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0] on linux - Operating system and architecture: Linux x86-64
Linked PRs
- gh-137804
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 平均合併
- 1 天 9 小時
- 30 天內合併 PR
- 558
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/cpython 的其他 Issue
-
docs pending
難度 2/5 1-3 小時 新手友好度 78/100
-
stdlib type-feature
難度 2/5 1-3 小時 新手友好度 78/100
-
stdlib type-feature
難度 2/5 1-3 小時 新手友好度 72/100
-
build type-bug
難度 2/5 1-3 小時 新手友好度 76/100
-
stdlib topic-email type-feature
難度 2/5 1-3 小時 新手友好度 70/100
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 90/100
-
bug
難度 2/5 1-3 小時 新手友好度 86/100
zostera/django-bootstrap4#894 ·
-
難度 2/5 1-3 小時 新手友好度 78/100
use-agent-os/agent-os#3276 ·
-
難度 2/5 1-3 小時 新手友好度 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
難度 2/5 1-3 小時 新手友好度 88/100
NousResearch/hermes-agent#117848 ·