mu-server: add a bit more debugging info

This commit is contained in:
Dirk-Jan C. Binnema 2022-05-30 20:30:33 +03:00
parent 59022e066d
commit 734445f78d
3 changed files with 26 additions and 5 deletions

View File

@ -64,6 +64,13 @@ static bool is_a_tty{};
static std::string hist_path;
static size_t max_lines{};
bool
Mu::have_readline()
{
return HAVE_READLINE != 0;
}
void
Mu::setup_readline(const std::string& histpath, size_t maxlines)
{

View File

@ -50,4 +50,12 @@ std::string read_line(bool& do_quit);
*/
void save_line(const std::string& line);
/**
* Do we have the non-shim readline?
*
* @return true or failse
*/
bool have_readline();
} // namespace Mu

View File

@ -35,13 +35,13 @@
#include "utils/mu-readline.hh"
using namespace Mu;
static std::atomic<bool> MuTerminate{false};
static std::atomic<int> MuTerminate{0};
static bool tty;
static void
sig_handler(int sig)
{
MuTerminate = true;
MuTerminate = sig;
}
static void
@ -50,7 +50,7 @@ install_sig_handler(void)
static struct sigaction action;
int i, sigs[] = {SIGINT, SIGHUP, SIGTERM, SIGPIPE};
MuTerminate = false;
MuTerminate = 0;
action.sa_handler = sig_handler;
sigemptyset(&action.sa_mask);
@ -123,10 +123,12 @@ Mu::mu_cmd_server(const MuConfig* opts) try {
return Err(store.error());
Server server{*store, output_sexp_stdout};
g_message("created server with store @ %s; maildir @ %s; debug-mode %s",
g_message("created server with store @ %s; maildir @ %s; debug-mode %s"
"readline: %s",
store->properties().database_path.c_str(),
store->properties().root_maildir.c_str(),
opts->debug ? "yes" : "no");
opts->debug ? "yes" : "no",
have_readline() ? "yes" : "no");
tty = ::isatty(::fileno(stdout));
const auto eval = std::string{opts->commands ? "(help :full t)"
@ -155,6 +157,10 @@ Mu::mu_cmd_server(const MuConfig* opts) try {
do_quit = server.invoke(line) ? false : true;
save_line(line);
}
if (MuTerminate != 0)
g_message ("shutting down due to signal %d", MuTerminate.load());
shutdown_readline();
return Ok();