When I have other threads running like the one to do reconnection to a socket then my app does not shut down cleanly. When it ends I get this message on the console:
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
and I get an unknown software exception (0x40000015).
If I add an XMLSocketAppender (with the fix for bug LOG4CXX-277) and the thread is sleeping then when main exits there is a delay (equal to the reconnectionDelay) then the exception occurs. I think the problem is that the SocketAppender is destroyed but the monitor thread is continuing to sleep when it wakes up it is not checking if it was interrupted like FileWatchdog does.
I can get rid of the exception by doing a thread.join in the close method and changing the monitor code to check for being interrupted like this:
if( !socketAppender->thread.interrupted() )
But that does not get rid of the delay waiting for the sleep to end. I don't understand why the sleep is not interrupted in this thread, but FileWatchdog does not have the same problem. The call to sleep from FileWatchdog does not keep the app from exiting. The sleep in FileWatchdog does not return if it is sleeping when the app exits.