From 5759832a7bf2ab051603b694c90c1f552aa0d084 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Sun, 3 Aug 2025 15:20:43 +0200 Subject: [PATCH] Fix os_exec_win --- base/tools/amake/main.c | 8 +++++++- base/tools/make.js | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/base/tools/amake/main.c b/base/tools/amake/main.c index 28d7a024..d25e4e9d 100644 --- a/base/tools/amake/main.c +++ b/base/tools/amake/main.c @@ -73,11 +73,17 @@ static JSValue js_os_exec_win(JSContext *ctx, JSValue this_val, int argc, JSValu CloseHandle(hReadPipe); WaitForSingleObject(pi.hProcess, INFINITE); + DWORD exit_code; + GetExitCodeProcess(pi.hProcess, &exit_code); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); printf("%s", buf); - return JS_NewString(ctx, buf); + + JSValue result = JS_NewObject(ctx); + JS_SetPropertyStr(ctx, result, "stdout", JS_NewString(ctx, buf)); + JS_SetPropertyStr(ctx, result, "status", JS_NewInt32(ctx, (int32_t)exit_code)); + return result; } #endif diff --git a/base/tools/make.js b/base/tools/make.js index 14364eeb..0de2e52b 100644 --- a/base/tools/make.js +++ b/base/tools/make.js @@ -135,8 +135,7 @@ function os_exec(exe, params = [], ops = {}) { let res = { status: 0 }; if (os_platform() === "win32") { - res.stdout = amake.os_exec_win(params, ops); - res.status = 0; + res = amake.os_exec_win(params, ops); // { status, stdout } } else { res.status = os.exec(params, ops);