In python (on a Linux system), I'm launching a command using os.system()
and retrieving the return code. If that return code is different from 0, I would like to make the program exit with that same return code. So I wrote:
ret = os.system(cmd)
if ret != 0:
print "exit with status %s" % ret
sys.exit(ret)
When the return code is lower than 256, it works fine, but when it's greater than 255, the exit code used is 0. How can I make sys.exit() accept codes greater than 255?
Edit: the limit is actually 255
In fact, the ret
variable receives 256, but sys.exit()
fails to use it, so the program returns 0 instead. When I launch cmd
manually, I see that it returns 1, not 256.