lua-users home
lua-l archive

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


Rici wrote:

> What you are seeing there is the behaviour of system(2);
> man system for more information.

and is right as usual.  The following program (compiled with
gcc on Linux) prints "system returned: 10752":

#include <stdio.h>
#include <stdlib.h>

int main(void) {
  printf("system returned: %d\n", system("lua -e 'os.exit(42)'"));
  return 0;
}

We had a reference here that describes system() as returning
the exit status itself or -1 if system() itself had a
problem, but K&R2 says only that it returns an
implementation-dependent int.  (Actually, it also says that
"In the UNIX system, the status return is the value returned
by exit", but that's obviously not true for either of the
systems I tried it on.)

-- 
Aaron