1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-05 19:31:04 +00:00

Avoid signal-unsafe operations in POSIX signal handler (#16160)

This commit is contained in:
JosiahWI 2025-06-01 08:24:32 -05:00 committed by GitHub
parent 56a7f0b7cf
commit 0bb87eb1ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 53 additions and 42 deletions

View file

@ -147,8 +147,8 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
/*
Menu-game loop
*/
bool retval = true;
bool *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) {
@ -540,9 +540,9 @@ bool ClientLauncher::launch_game(std::string &error_message,
void ClientLauncher::main_menu(MainMenuData *menudata)
{
bool *kill = porting::signal_handler_killstatus();
volatile auto *kill = porting::signal_handler_killstatus();
video::IVideoDriver *driver = m_rendering_engine->get_video_driver();
auto *device = m_rendering_engine->get_raw_device();
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;

View file

@ -65,6 +65,8 @@
#include "client/sound/sound_openal.h"
#endif
#include <csignal>
class NodeDugEvent : public MtEvent
{
public:
@ -561,7 +563,7 @@ public:
Game();
~Game();
bool startup(bool *kill,
bool startup(volatile std::sig_atomic_t *kill,
InputHandler *input,
RenderingEngine *rendering_engine,
const GameStartData &game_params,
@ -793,14 +795,14 @@ private:
This class does take ownership/responsibily for cleaning up etc of any of
these items (e.g. device)
*/
IrrlichtDevice *device;
RenderingEngine *m_rendering_engine;
video::IVideoDriver *driver;
scene::ISceneManager *smgr;
bool *kill;
std::string *error_message;
bool *reconnect_requested;
PausedNodesList paused_animated_nodes;
IrrlichtDevice *device;
RenderingEngine *m_rendering_engine;
video::IVideoDriver *driver;
scene::ISceneManager *smgr;
volatile std::sig_atomic_t *kill;
std::string *error_message;
bool *reconnect_requested;
PausedNodesList paused_animated_nodes;
bool simple_singleplayer_mode;
/* End 'cache' */
@ -932,7 +934,7 @@ Game::~Game()
m_rendering_engine->finalize();
}
bool Game::startup(bool *kill,
bool Game::startup(volatile std::sig_atomic_t *kill,
InputHandler *input,
RenderingEngine *rendering_engine,
const GameStartData &start_data,
@ -4235,7 +4237,7 @@ void Game::readSettings()
****************************************************************************/
/****************************************************************************/
void the_game(bool *kill,
void the_game(volatile std::sig_atomic_t *kill,
InputHandler *input,
RenderingEngine *rendering_engine,
const GameStartData &start_data,

View file

@ -6,6 +6,7 @@
#include "irrlichttypes.h"
#include "config.h"
#include <csignal>
#include <string>
#if !IS_CLIENT_BUILD
@ -36,7 +37,7 @@ struct CameraOrientation {
#define GAME_FALLBACK_TIMEOUT 1.8f
#define GAME_CONNECTION_TIMEOUT 10.0f
void the_game(bool *kill,
void the_game(volatile std::sig_atomic_t *kill,
InputHandler *input,
RenderingEngine *rendering_engine,
const GameStartData &start_data,