python / python/cpython

os.execvp on windows doesn't wait for the executed program to finish and doesn't report it's exit code

オープン
#101,191 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

OS-windows type-bug
主要言語
Python
スター
77.2k
フォーク
36k
PR マージ指標
PR 指標を取得中

説明

Bug report

os.execvp on windows doesn't wait for the executed program to finish and doesn't report it's exit code. Code:

import os
import sys

if len(sys.argv) > 1 and sys.argv[1] == "my_argument":
    sys.stderr.write("my_argument detected. Exiting with code 1.\n")
    sys.exit(1)
else:
    sys.stderr.write("no argument detected. Calling os.execvp\n")
    os.execvp(sys.executable, [sys.executable] + sys.argv + ["my_argument"])

bat file:

@echo off
python exec.py
if %errorlevel% NEQ 0 (
    echo The script gave exit code %errorlevel%
) else (
    echo Error: The script exited with exit code 0
)

Output from command prompt:

C:\pythonizer\play>exec.bat
no argument detected. Calling os.execvp
Error: The script exited with exit code 0

C:\pythonizer\play>my_argument detected. Exiting with code 1.

Note the command prompt prompted me for a new command before the exec'd process wrote out it's message.

Your environment

  • CPython versions tested on: 3.10.6
  • Operating system and architecture: Windows 10

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供された Python スクリプトとバッチ ファイルを使って Windows 10 の動作を再現し、次に os.execvp のエントリポイントとその Windows 実装を追跡します。実行されたプログラムがバッチ ファイルの処理継続前に終了し、その 0 以外の終了コードが呼び出し元に報告されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
operating-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。