ww (selfhost): procrun propagates the real child exit code (fix #16)
The shared fork/exec/wait helper collapsed every non-zero child exit to 1, so `ww_ww run <prog>` lost the program's real exit status (return 42 -> exit 1). The C ww driver's do_run returns WEXITSTATUS(status) — the exact code. procrun now returns the real exit code instead of folding to 1; signal kill still returns 1 and fork/wait failure still returns -1, matching do_run. procrun is shared with the build-step callers (w6c/w6a/w6l), but they only test `!= 0` (success vs failure), so a real non-zero code is still `!= 0` — they are unaffected. dorun's final exec then reports the true program exit code. Driver behavior is not under byte-id (993 pins build_one output bytes, not wait-status handling); 993 extended with table-driven run exit-code rows (0/7/42) that fail under the old collapse-to-1.
This commit is contained in:
@@ -2986,8 +2986,11 @@ fn joinpathlit(dir: *u8, name: str) *u8 = {
|
||||
// ---- Subprocess plumbing ----------------------------------------------
|
||||
|
||||
// procrun — fork, execve `path` with `argv` (NULL-terminated), wait.
|
||||
// Returns 0 on clean exit-0, 1 on any non-zero exit or signal kill,
|
||||
// -1 on fork/wait failure.
|
||||
// Returns the child's real exit code on clean exit, 1 on signal kill,
|
||||
// -1 on fork/wait failure. Mirrors cmd/ww/main.c:do_run WEXITSTATUS:
|
||||
// the build-step callers only test `!= 0`, so propagating the exact
|
||||
// non-zero code leaves them unaffected while `dorun` reports the true
|
||||
// program exit status (was collapsing every non-zero exit to 1; fix #16).
|
||||
fn procrun(path: *u8, argv: **u8) i32 = {
|
||||
let pid: i32 = os.fork();
|
||||
if (pid < 0) {
|
||||
@@ -3009,8 +3012,7 @@ fn procrun(path: *u8, argv: **u8) i32 = {
|
||||
// next byte = exit code.
|
||||
if ((status & 127i32) != 0) { return 1; };
|
||||
let code: i32 = (status >> 8i32) & 255i32;
|
||||
if (code != 0) { return 1; };
|
||||
return 0;
|
||||
return code;
|
||||
};
|
||||
|
||||
// ---- `use` resolution + source concatenation --------------------------
|
||||
|
||||
@@ -152,8 +152,11 @@ fn joinpathlit(dir: *u8, name: str) *u8 = {
|
||||
// ---- Subprocess plumbing ----------------------------------------------
|
||||
|
||||
// procrun — fork, execve `path` with `argv` (NULL-terminated), wait.
|
||||
// Returns 0 on clean exit-0, 1 on any non-zero exit or signal kill,
|
||||
// -1 on fork/wait failure.
|
||||
// Returns the child's real exit code on clean exit, 1 on signal kill,
|
||||
// -1 on fork/wait failure. Mirrors cmd/ww/main.c:do_run WEXITSTATUS:
|
||||
// the build-step callers only test `!= 0`, so propagating the exact
|
||||
// non-zero code leaves them unaffected while `dorun` reports the true
|
||||
// program exit status (was collapsing every non-zero exit to 1; fix #16).
|
||||
fn procrun(path: *u8, argv: **u8) i32 = {
|
||||
let pid: i32 = os.fork();
|
||||
if (pid < 0) {
|
||||
@@ -175,8 +178,7 @@ fn procrun(path: *u8, argv: **u8) i32 = {
|
||||
// next byte = exit code.
|
||||
if ((status & 127i32) != 0) { return 1; };
|
||||
let code: i32 = (status >> 8i32) & 255i32;
|
||||
if (code != 0) { return 1; };
|
||||
return 0;
|
||||
return code;
|
||||
};
|
||||
|
||||
// ---- `use` resolution + source concatenation --------------------------
|
||||
|
||||
Reference in New Issue
Block a user