lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On 15-Oct-04, at 1:27 PM, Aaron Brown wrote:

Hey folks,

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().