Jump to content

Fix for onExit not called on Linux/BSD :: posix


Recommended Posts

I found this in 3.10 but 4.x code looks the same so I guess it does not work there also. So I share my findings here:

The  (package) onExit scripts  are not called and so the prefs are not saved.

On Windows the Process::requestShutdown(); is called so the StandardMainLoop can finish and  onExit is called. 
On Unix/Posix only  _exit is executed  and then onExit's in script's packages are never called.

The solution is simple: I changed it to the way the windows platform code does it:

in file x86UNIXProcessControl.cpp (3.10) or file POSIXProcessControl.cpp ( 4.current)

add the include:

#include "core/util/journal/process.h"

and in Platform::postQuitMessage(const S32 in_quitVal) add the code at the beginning of the void:


Maybe in_quitVal should be handled if it's not 0 and forceShutdown(in_quitVal); should be called instead. Not validated so far.
But on Windows Platform ignore the in_quitVal, also.

Edited by ohmtal
Link to comment
Share on other sites

  • 2 weeks later...

Apologies for the delay in reply @ohmtal

I gave it a shot, and so did practicing, and with your suggested change in neither case did we see onExit() or the module's onDestroy() get called on Linux.

Is it possible there was another change you did somewhere that was also needed for the fix?

Link to comment
Share on other sites

I gave it a try on Linux. Compiled the current (4.x) sources. Added an echo to core.tscitpt onExit, started the binary and exit again. OnExit was not called.

Then I added the changes, compiled and tried again. The onExit was not called but the prefs were exported.

Double checked it and the prefs (onDestroy) are only exported when the changes are applied. I did not try to find out why the core.tscitpt's onExit is not called.

Edited by ohmtal
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...