mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Make changes requested by sfan5
* Use `auto` for temporary locals instead of `std::sig_atomic_t` * Use stderr instead of stdout for logging messages. * Remove old commented out code. * Do not write null byte when logging.
This commit is contained in:
parent
5791f5ff8b
commit
053ff1bc23
3 changed files with 12 additions and 21 deletions
|
@ -22,7 +22,6 @@
|
|||
#include "util/tracy_wrapper.h"
|
||||
#include <IGUISpriteBank.h>
|
||||
#include <ICameraSceneNode.h>
|
||||
#include <csignal>
|
||||
#include <unordered_map>
|
||||
|
||||
#if USE_SOUND
|
||||
|
@ -148,8 +147,8 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
|
|||
/*
|
||||
Menu-game loop
|
||||
*/
|
||||
bool retval = true;
|
||||
volatile std::sig_atomic_t *kill = porting::signal_handler_killstatus();
|
||||
bool retval = true;
|
||||
volatile auto *kill = porting::signal_handler_killstatus();
|
||||
|
||||
while (m_rendering_engine->run() && !*kill &&
|
||||
!g_gamecallback->shutdown_requested) {
|
||||
|
@ -530,9 +529,9 @@ bool ClientLauncher::launch_game(std::string &error_message,
|
|||
|
||||
void ClientLauncher::main_menu(MainMenuData *menudata)
|
||||
{
|
||||
volatile std::sig_atomic_t *kill = porting::signal_handler_killstatus();
|
||||
video::IVideoDriver *driver = m_rendering_engine->get_video_driver();
|
||||
auto *device = m_rendering_engine->get_raw_device();
|
||||
volatile auto *kill = porting::signal_handler_killstatus();
|
||||
video::IVideoDriver *driver = m_rendering_engine->get_video_driver();
|
||||
auto *device = m_rendering_engine->get_raw_device();
|
||||
|
||||
// Wait until app is in foreground because of #15883
|
||||
infostream << "Waiting for app to be in foreground" << std::endl;
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -46,8 +46,6 @@ extern "C" {
|
|||
#endif
|
||||
}
|
||||
|
||||
#include <csignal>
|
||||
|
||||
#if !defined(__cpp_rtti) || !defined(__cpp_exceptions)
|
||||
#error Luanti cannot be built without exceptions or RTTI
|
||||
#endif
|
||||
|
@ -1140,7 +1138,7 @@ static bool run_dedicated_server(const GameParams &game_params, const Settings &
|
|||
return false;
|
||||
}
|
||||
ChatInterface iface;
|
||||
volatile std::sig_atomic_t &kill = *porting::signal_handler_killstatus();
|
||||
volatile auto &kill = *porting::signal_handler_killstatus();
|
||||
|
||||
try {
|
||||
// Create server
|
||||
|
@ -1183,7 +1181,7 @@ static bool run_dedicated_server(const GameParams &game_params, const Settings &
|
|||
server.start();
|
||||
|
||||
// Run server
|
||||
volatile std::sig_atomic_t &kill = *porting::signal_handler_killstatus();
|
||||
volatile auto &kill = *porting::signal_handler_killstatus();
|
||||
dedicated_server_loop(server, kill);
|
||||
|
||||
} catch (const ModError &e) {
|
||||
|
@ -1228,7 +1226,7 @@ static bool migrate_map_database(const GameParams &game_params, const Settings &
|
|||
|
||||
u32 count = 0;
|
||||
u64 last_update_time = 0;
|
||||
volatile std::sig_atomic_t &kill = *porting::signal_handler_killstatus();
|
||||
volatile auto &kill = *porting::signal_handler_killstatus();
|
||||
|
||||
std::vector<v3s16> blocks;
|
||||
old_db->listAllLoadableBlocks(blocks);
|
||||
|
@ -1282,7 +1280,7 @@ static bool recompress_map_database(const GameParams &game_params, const Setting
|
|||
|
||||
u32 count = 0;
|
||||
u64 last_update_time = 0;
|
||||
volatile std::sig_atomic_t &kill = *porting::signal_handler_killstatus();
|
||||
volatile auto &kill = *porting::signal_handler_killstatus();
|
||||
const u8 serialize_as_ver = SER_FMT_VER_HIGHEST_WRITE;
|
||||
const s16 map_compression_level = rangelim(g_settings->getS16("map_compression_level_disk"), -1, 9);
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ volatile std::sig_atomic_t *signal_handler_killstatus()
|
|||
}
|
||||
|
||||
#if !defined(_WIN32) // POSIX
|
||||
#define STDOUT 1
|
||||
#define STDERR_FILENO 2
|
||||
|
||||
static void signal_handler(int sig)
|
||||
{
|
||||
|
@ -98,18 +98,12 @@ static void signal_handler(int sig)
|
|||
if (sig == SIGINT) {
|
||||
const char *dbg_text{"INFO: signal_handler(): "
|
||||
"Ctrl-C pressed, shutting down.\n"};
|
||||
write(STDOUT, dbg_text, strlen(dbg_text) + 1);
|
||||
write(STDERR_FILENO, dbg_text, strlen(dbg_text));
|
||||
} else if (sig == SIGTERM) {
|
||||
const char *dbg_text{"INFO: signal_handler(): "
|
||||
"got SIGTERM, shutting down.\n"};
|
||||
write(STDOUT, dbg_text, strlen(dbg_text) + 1);
|
||||
write(STDERR_FILENO, dbg_text, strlen(dbg_text));
|
||||
}
|
||||
|
||||
// Comment out for less clutter when testing scripts
|
||||
/*dstream << "INFO: sigint_handler(): "
|
||||
<< "Printing debug stacks" << std::endl;
|
||||
debug_stacks_print();*/
|
||||
|
||||
g_killed = true;
|
||||
} else {
|
||||
(void)signal(sig, SIG_DFL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue