upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbitflash <dev@bitflash.network>2026-08-19 11:34:12 -0300
committerbitflash <dev@bitflash.network>2026-08-19 11:34:12 -0300
commit0cdcaee550093707b92827e7457ef33c1bf70fb5 (patch)
tree113ec9ece886ff02fb24d3c7fcf838e9d6376456
parente5a0a8fb8c83323ebd4fce88b84ae1b9f4570edc (diff)
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.
-rw-r--r--src/selftest.cpp11
1 files changed, 10 insertions, 1 deletions
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 @@
10#include "bip32.h" 10#include "bip32.h"
11#include "proxy.h" 11#include "proxy.h"
12#include "selftest.h" 12#include "selftest.h"
13#ifndef _WIN32
14#include <sys/wait.h> // WIFEXITED/WEXITSTATUS for the child-process helper
15#endif
13#include "sockcount.h" 16#include "sockcount.h"
14#include "tor.h" 17#include "tor.h"
15#include "walletcmd.h" 18#include "walletcmd.h"
@@ -2110,7 +2113,13 @@ static int RunBitflashChild(const string& strExe,
2110 strCmd += " > " + QuoteCommandArg(*pOutputFile) + " 2>&1"; 2113 strCmd += " > " + QuoteCommandArg(*pOutputFile) + " 2>&1";
2111 else 2114 else
2112 strCmd += " > /dev/null 2>&1"; 2115 strCmd += " > /dev/null 2>&1";
2113 return system(strCmd.c_str()); 2116 // system() returns a wait status, not the exit code; unwrap it so callers
2117 // see the same value the Windows _spawnv path returns (e.g. exit code 2 is
2118 // 2, not 512). Without this every "== 2" assertion fails only on Linux.
2119 int nSysRet = system(strCmd.c_str());
2120 if (nSysRet != -1 && WIFEXITED(nSysRet))
2121 return WEXITSTATUS(nSysRet);
2122 return nSysRet;
2114#endif 2123#endif
2115} 2124}
2116 2125