[New-bugs-announce] [issue13792] The "os.execl" call doesn't give programs exit code

Kay Hayen report at bugs.python.org
Mon Jan 16 00:05:04 CET 2012

New submission from Kay Hayen <kayhayen at gmx.de>:


I am the author of the Python compiler Nuitka. It has the ability to immediately execute the created executable file. For that I am using "os.execl" to immediately replace the compiler and run the freshly created binary instead.

This worked well so far, but as of late, I am also checking the exit codes, and it turns out that even for failing programs, the exit code is "0" on Windows, even though the compiled binary is exiting with "1".

Investigating further, I made a simple program:

import os
os.execl( "FailingProgram.exe", "lala" )

And it turns out, it's giving me "0", whereas when executed directly "FailingProgram.exe" gives "1". Checking %errorlevel% manually that is, my test framework uses "subprocess" module and gets "0".

The same code works fine (preserves exit code) under Linux. I didn't find the windows specific code responsible for implementing "os.execv" under Win32. I am suspecting that somehow "cmd.exe" may not be propagating the error code, but for that to confirm I would need pointers.

Thanks in advance,

components: Library (Lib)
messages: 151304
nosy: kayhayen
priority: normal
severity: normal
status: open
title: The "os.execl" call doesn't give programs exit code
type: behavior
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list