os.execvp on windows doesn't wait for the executed program to finish and doesn't report it's exit code
Open
Nobody has claimed this yet.
OS-windows
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Windows 10 behavior with the provided Python script and batch file, then trace the os.execvp entry point and its Windows implementation. Done means the executed program finishes before the batch file continues and its nonzero exit code is reported to the caller.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100