diff --git a/ion/src/simulator/shared/events_platform.cpp b/ion/src/simulator/shared/events_platform.cpp index e1f322820..8dfc68671 100644 --- a/ion/src/simulator/shared/events_platform.cpp +++ b/ion/src/simulator/shared/events_platform.cpp @@ -1,5 +1,6 @@ #include "actions.h" #include "events.h" +#include "journal.h" #include "keyboard.h" #include "layout.h" #include "state_file.h" @@ -182,6 +183,13 @@ Event getPlatformEvent() { * the subsequent ones. */ SDL_FlushEvents(0, UINT32_MAX); } + if (Simulator::Window::isHeadless()) { + if (Simulator::Journal::replayJournal() == nullptr || Simulator::Journal::replayJournal()->isEmpty()) { + /* We don't want to keep the simulator process alive if there's no chance + * we're ever going to provide it with new events to process. */ + return Termination; + } + } return result; }