diff options
| author | Mike <contact@mikelittman.me> | 2026-10-14 00:04:11 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-10-14 13:04:11 +0800 |
| commit | 4d3ec2142c2fcafec17425284a59134f62c3f8b7 (patch) | |
| tree | 1a167e4b946da44f1ed3888850898b48a0db45fc /indra/llcommon/llapp.cpp | |
| parent | 9cc783022a202a1d00b5dc8eaf01ffddbc9fa39f (diff) | |
Log out before exiting on the first terminate signal (#35)
SIGTERM was marking the app quitting immediately, so the Mac frame
pump stopped before LogoutRequest and the simulator kept the agent
in the region. The first signal now runs the normal logout. A second
signal still forces the process to exit.
Diffstat (limited to 'indra/llcommon/llapp.cpp')
| -rw-r--r-- | indra/llcommon/llapp.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index 02d6da989a..278a8f7c2f 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -28,6 +28,7 @@ #include "llapp.h" +#include <csignal> #include <cstdlib> #ifdef LL_DARWIN @@ -397,6 +398,22 @@ void LLApp::writeMiniDump() { } +namespace +{ + volatile sig_atomic_t sTermCount = 0; +} + +// static +bool LLApp::consumeSignalQuit() +{ + if (sTermCount == 0) + { + return false; + } + sTermCount = 0; + return true; +} + // static void LLApp::setQuitting() { @@ -623,18 +640,19 @@ void default_unix_signal_handler(int signum, siginfo_t *info, void *) { LL_WARNS() << "Signal handler - Got SIGINT, or TERM, exiting gracefully" << LL_ENDL; } - // Graceful exit - // Just set our state to quitting, not error - if (LLApp::isQuitting() || LLApp::isError()) + // The first signal asks the main loop to log out. setQuitting() here + // makes the Mac frame pump return immediately, so LogoutRequest is + // never sent and the simulator keeps the agent in the region. + if (sTermCount > 0 || LLApp::isQuitting() || LLApp::isError()) { - // We're already trying to die, just ignore this signal if (LLApp::sLogInSignal) { - LL_INFOS() << "Signal handler - Already trying to quit, ignoring signal!" << LL_ENDL; + LL_INFOS() << "Signal handler - Already trying to quit, forcing exit" << LL_ENDL; } + LLApp::setQuitting(); return; } - LLApp::setQuitting(); + sTermCount = 1; return; case SIGALRM: case SIGPIPE: |
