mirror of https://github.com/djcb/mu.git
mu-server: add a bit more debugging info
This commit is contained in:
parent
59022e066d
commit
734445f78d
|
@ -64,6 +64,13 @@ static bool is_a_tty{};
|
||||||
static std::string hist_path;
|
static std::string hist_path;
|
||||||
static size_t max_lines{};
|
static size_t max_lines{};
|
||||||
|
|
||||||
|
bool
|
||||||
|
Mu::have_readline()
|
||||||
|
{
|
||||||
|
return HAVE_READLINE != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Mu::setup_readline(const std::string& histpath, size_t maxlines)
|
Mu::setup_readline(const std::string& histpath, size_t maxlines)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,4 +50,12 @@ std::string read_line(bool& do_quit);
|
||||||
*/
|
*/
|
||||||
void save_line(const std::string& line);
|
void save_line(const std::string& line);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do we have the non-shim readline?
|
||||||
|
*
|
||||||
|
* @return true or failse
|
||||||
|
*/
|
||||||
|
bool have_readline();
|
||||||
|
|
||||||
} // namespace Mu
|
} // namespace Mu
|
||||||
|
|
|
@ -35,13 +35,13 @@
|
||||||
#include "utils/mu-readline.hh"
|
#include "utils/mu-readline.hh"
|
||||||
|
|
||||||
using namespace Mu;
|
using namespace Mu;
|
||||||
static std::atomic<bool> MuTerminate{false};
|
static std::atomic<int> MuTerminate{0};
|
||||||
static bool tty;
|
static bool tty;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sig_handler(int sig)
|
sig_handler(int sig)
|
||||||
{
|
{
|
||||||
MuTerminate = true;
|
MuTerminate = sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -50,7 +50,7 @@ install_sig_handler(void)
|
||||||
static struct sigaction action;
|
static struct sigaction action;
|
||||||
int i, sigs[] = {SIGINT, SIGHUP, SIGTERM, SIGPIPE};
|
int i, sigs[] = {SIGINT, SIGHUP, SIGTERM, SIGPIPE};
|
||||||
|
|
||||||
MuTerminate = false;
|
MuTerminate = 0;
|
||||||
|
|
||||||
action.sa_handler = sig_handler;
|
action.sa_handler = sig_handler;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
|
@ -123,10 +123,12 @@ Mu::mu_cmd_server(const MuConfig* opts) try {
|
||||||
return Err(store.error());
|
return Err(store.error());
|
||||||
|
|
||||||
Server server{*store, output_sexp_stdout};
|
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().database_path.c_str(),
|
||||||
store->properties().root_maildir.c_str(),
|
store->properties().root_maildir.c_str(),
|
||||||
opts->debug ? "yes" : "no");
|
opts->debug ? "yes" : "no",
|
||||||
|
have_readline() ? "yes" : "no");
|
||||||
|
|
||||||
tty = ::isatty(::fileno(stdout));
|
tty = ::isatty(::fileno(stdout));
|
||||||
const auto eval = std::string{opts->commands ? "(help :full t)"
|
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;
|
do_quit = server.invoke(line) ? false : true;
|
||||||
save_line(line);
|
save_line(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MuTerminate != 0)
|
||||||
|
g_message ("shutting down due to signal %d", MuTerminate.load());
|
||||||
|
|
||||||
shutdown_readline();
|
shutdown_readline();
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
|
|
Loading…
Reference in New Issue