diff options
| author | bitflash <dev@bitflash.network> | 2026-08-19 09:48:07 -0300 |
|---|---|---|
| committer | bitflash <dev@bitflash.network> | 2026-08-19 09:48:07 -0300 |
| commit | d4c49085a10c0f7c3f5a1dcc72184938dca38fea (patch) | |
| tree | 03143252c9b3dd46a4fcfa01c27223b26a4e33e5 /src/main_gui.cpp | |
| parent | cf155d40ddd260975240e72b5e72cd3decc30291 (diff) | |
gui: harden the restart relaunch (ultra edge cases)
Follow-up to the Restart Now button. Addresses the edge cases the review
flagged, and drops the fragile batch layer entirely:
- Windows no longer writes a .bat and shells through cmd (which re-parsed
the arguments and could leave a stray file on failure). It builds the
command line once, quoted correctly (only backslashes before a quote are
doubled, so ordinary paths are not mangled), and CreateProcess launches
the new instance directly.
- The delay moved into the new instance: a -restartwait flag makes it wait
~2.5s before it opens the network port and the block index, so the old
process is gone first. No shell delay hack. Verified: -restartwait adds
the wait (0.16s -> 2.67s).
- Linux re-execs /proc/self/exe (absolute) and only falls back to argv[0],
which may be relative or a bare PATH name that execv cannot resolve.
- This instance now exits only if the relaunch actually started; on failure
it keeps running and tells the user to restart manually, so a failed
relaunch never leaves them with no node.
GUI/process wiring only; wallet code unchanged, suites still green.
Diffstat (limited to 'src/main_gui.cpp')
| -rw-r--r-- | src/main_gui.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 6cd8b75..55ca8c6 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp | |||
| @@ -509,6 +509,14 @@ int main(int argc, char* argv[]) | |||
| 509 | 509 | ||
| 510 | ParseStartupArguments(argc, argv); | 510 | ParseStartupArguments(argc, argv); |
| 511 | 511 | ||
| 512 | #ifdef _WIN32 | ||
| 513 | // Set by the GUI "Restart Now" button: give the previous instance a moment | ||
| 514 | // to release the network port and the block-index files before this one | ||
| 515 | // opens them, so a relaunch does not race the process it is replacing. | ||
| 516 | if (arg(argc, argv, "/restartwait") || arg(argc, argv, "-restartwait")) | ||
| 517 | Sleep(2500); | ||
| 518 | #endif | ||
| 519 | |||
| 512 | // Hidden self-test helper. It must run before LoadWallet(): several | 520 | // Hidden self-test helper. It must run before LoadWallet(): several |
| 513 | // storage-sanity scenarios deliberately make wallet.dat unsafe to load. | 521 | // storage-sanity scenarios deliberately make wallet.dat unsafe to load. |
| 514 | string strSelfTestMutateWallet = | 522 | string strSelfTestMutateWallet = |