[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: os.exit()/os.execute() behaviour (Lua 5.1)
- From: Brad Jorsch <bjorsch@...>
- Date: Fri, 17 May 2013 12:55:47 -0400
On Fri, May 17, 2013 at 12:16 PM, Gyepi SAM <email@example.com> wrote:
> We need to make a distinction here between wait() and system().
> Everything written here applies to wait, but does differ for system()
> because system calls "/bin/sh -c" (or the moral equivalent) and returns
> the shell's exit code. When a process terminates normally, the shell returns
> its exit code. However, when the process is terminated by a signal, it
> returns 128 + the signal number.
Well, not exactly. Everything about wait() does apply to system(),
it's just that the intervening shell layer may result in a different
status returned than would if you had called the process directly.
So if the invoked process segfaults, then the shell translates that
into an exit code (often 139) with no signals. But if the shell
segfaults, you'll still get the signal (often 11) as you would with