From 0cdcaee550093707b92827e7457ef33c1bf70fb5 Mon Sep 17 00:00:00 2001 From: bitflash Date: Wed, 19 Aug 2026 11:34:12 -0300 Subject: selftest: unwrap system() exit status on Linux (RunBitflashChild) The Linux branch of the child-process helper returned system()s raw wait status instead of the exit code, so an exit code of 2 read back as 512. Every assertion that checks a specific code (== 2), like the locked recovery-audit test, failed only on Linux while the node itself was correct. Windows was unaffected (_spawnv returns the code directly). Unwrap with WIFEXITED/WEXITSTATUS so both platforms return the same value. Test harness only; no change to node behavior. --- src/selftest.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/selftest.cpp b/src/selftest.cpp index a9c73fe..dc9936e 100644 --- a/src/selftest.cpp +++ b/src/selftest.cpp @@ -10,6 +10,9 @@ #include "bip32.h" #include "proxy.h" #include "selftest.h" +#ifndef _WIN32 +#include // WIFEXITED/WEXITSTATUS for the child-process helper +#endif #include "sockcount.h" #include "tor.h" #include "walletcmd.h" @@ -2110,7 +2113,13 @@ static int RunBitflashChild(const string& strExe, strCmd += " > " + QuoteCommandArg(*pOutputFile) + " 2>&1"; else strCmd += " > /dev/null 2>&1"; - return system(strCmd.c_str()); + // system() returns a wait status, not the exit code; unwrap it so callers + // see the same value the Windows _spawnv path returns (e.g. exit code 2 is + // 2, not 512). Without this every "== 2" assertion fails only on Linux. + int nSysRet = system(strCmd.c_str()); + if (nSysRet != -1 && WIFEXITED(nSysRet)) + return WEXITSTATUS(nSysRet); + return nSysRet; #endif } -- cgit v1.2.3