diff --git a/frontend/device/pocketbook/device.lua b/frontend/device/pocketbook/device.lua index 501f563f8..bb8f38065 100644 --- a/frontend/device/pocketbook/device.lua +++ b/frontend/device/pocketbook/device.lua @@ -256,6 +256,21 @@ function PocketBook:init() Generic.init(self) end +function PocketBook:exit() + Generic.exit(self) + + -- Exit code can be shoddy on some devices due to broken library dtors calling _exit(0) from os.exit(N) + local ko_exit = os.getenv("KO_EXIT_CODE") + if ko_exit then + local fo = io.open(ko_exit, "w+") + if fo then + -- As returned by UIManager:run() in reader.lua + fo:write(tostring(UIManager._exit_code)) + fo:close() + end + end +end + function PocketBook:notifyBookState(title, document) local fn = document and document.file logger.dbg("Notify book state", title, fn) diff --git a/reader.lua b/reader.lua index d62a2d70a..e6903f5bb 100755 --- a/reader.lua +++ b/reader.lua @@ -324,16 +324,6 @@ end -- Exit local function exitReader() - -- Exit code can be shoddy on some platforms due to broken library dtors calling _exit(0) from os.exit(N) - local ko_exit = os.getenv("KO_EXIT_CODE") - if ko_exit then - local fo = io.open(ko_exit, "w+") - if fo then - fo:write(tostring(exit_code)) - fo:close() - end - end - -- Save any device settings before closing G_reader_settings Device:saveSettings()