exec: Don't format status returned directly from builtin function

The builtin function returns the raw status, which is not the same as
the integer return by waitpid. Therefore, the WIF macros shouldn't be
used for checking or obtaining the status.

This bug can be seen by executing (eval false). The builtin eval
function returns 1, but proc_format_status misinterprets it as a signal
by checking WIFSIGNALED, so adds 128 to the status to return 129.

Signed-off-by: Grissiom <chaos.proton@gmail.com>
This commit is contained in:
Dylan Smith 2010-11-24 00:27:16 +08:00 committed by Grissiom
parent 9f3a4d1640
commit 364d3dbbf8

2
exec.c
View file

@ -1575,7 +1575,7 @@ void exec( job_t *j )
{
debug( 3, L"Set status of %ls to %d using short circut", j->command, p->status );
int status = proc_format_status(p->status);
int status = p->status;
proc_set_last_status( job_get_flag( j, JOB_NEGATE )?(!status):status );
}
break;