Revert "no memory leak"

This reverts commit fe66d52a38.
This commit is contained in:
Anton Samokhvalov 2021-12-29 15:46:15 +03:00
parent fe66d52a38
commit c1f540e61e
2 changed files with 7 additions and 10 deletions

View file

@ -237,15 +237,15 @@ void clean_quit(int sig) {
std::cerr << Global::fg_red << "ERROR: " << Global::fg_white << Global::exit_error_msg << Fx::reset << endl; std::cerr << Global::fg_red << "ERROR: " << Global::fg_white << Global::exit_error_msg << Fx::reset << endl;
} }
Logger::info("Quitting! Runtime: " + sec_to_dhms(time_s() - Global::start_time)); Logger::info("Quitting! Runtime: " + sec_to_dhms(time_s() - Global::start_time));
close(0);
const auto excode = (sig != -1 ? sig : 0);
//? Assume error if still not cleaned up and call quick_exit to avoid a segfault from Tools::atomic_lock destructor //? Assume error if still not cleaned up and call quick_exit to avoid a segfault from Tools::atomic_lock destructor
#ifndef __APPLE__ #ifndef __APPLE__
if (Tools::active_locks > 0) { quick_exit(excode);
quick_exit((sig != -1 ? sig : 0));
}
#endif #endif
if (sig != -1) exit(sig); exit(excode);
} }
//* Handler for SIGTSTP; stops threads, restores terminal and sends SIGSTOP //* Handler for SIGTSTP; stops threads, restores terminal and sends SIGSTOP

View file

@ -82,14 +82,10 @@ namespace Input {
struct InputThr { struct InputThr {
InputThr() : thr(run, this) { InputThr() : thr(run, this) {
thr.detach();
} }
static void run(InputThr* that) { static void run(InputThr* that) {
try { that->runImpl();
that->runImpl();
} catch (...) {}
delete that;
} }
void runImpl() { void runImpl() {
@ -124,6 +120,7 @@ namespace Input {
} }
static InputThr& instance() { static InputThr& instance() {
// intentional memory leak, to simplify shutdown process
static InputThr* input = new InputThr(); static InputThr* input = new InputThr();
return *input; return *input;