osd: Stop on SIGINT/SIGTERM from the main loop, not the signal handler #141

Merged
vitalif merged 1 commits from koolkhel/vitastor:osd-signal-stop into master 2026-11-20 19:10:55 +03:00

View File

@@ -7,19 +7,19 @@
#include <sys/prctl.h>
#include <signal.h>
#include <unistd.h>
static osd_t *osd = NULL;
static bool force_stopping = false;
static volatile sig_atomic_t stop_signal = 0;
// Only async-signal-safe calls are allowed here, the OSD is stopped by the main loop
static void handle_sigint(int sig)
{
if (osd && !force_stopping)
if (stop_signal)
{
force_stopping = true;
osd->force_stop(0);
return;
_exit(0);
}
exit(0);
stop_signal = 1;
}
static const char* help_text =
@@ -83,9 +83,15 @@ int main(int narg, char *args[])
return 1;
}
osd->start();
bool force_stopping = false;
while (1)
{
ringloop->loop();
if (stop_signal && !force_stopping)
{
force_stopping = true;
osd->force_stop(0);
}
ringloop->wait();
}
delete osd;