[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: os.execute returns munged exit status
- From: "Aaron Brown" <aaron-lua@...>
- Date: Fri, 15 Oct 2004 15:25:31 -0400
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