[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: os.execute returns munged exit status
- From: Rici Lake <lua@...>
- Date: Fri, 15 Oct 2004 13:48:15 -0500
On 15-Oct-04, at 1:27 PM, Aaron Brown wrote:
Instead of returning the shell's exit status, os.execute
returns that exit status multiplied by 256 (i.e., shifted
over one byte). I assume that's not intentional.
What you are seeing there is the behaviour of system(2);
man system for more information.
Basically, system() needs to be able to return various exit
conditions other than the exit code; for example, the process
might have terminated as the result of a signal (which
includes the case where it segfaults), or system() might
not have been able to start the process at all.
So if the process exits "normally" with a result code,
the last byte of the result code is multiplied by 256 and
returned by system().