Norman Vine wrote:
but FGFS still won't exit with out a 'ctrl-c' or other forcedI can't check this one myself because the new ATC code needs some more attention fro IRIX, but could you give this patch a try?
sig quit with the existing static FGTileManager whereas
it exits with a dynamically allocated one that automagically calls its destructor at exit time
In theory it should work, but ...
Erik
diff -Nuar /home/erik/src/CVS/fgfs/SimGear/simgear/threads/SGThread.cxx
threads/SGThread.cxx
--- /home/erik/src/CVS/fgfs/SimGear/simgear/threads/SGThread.cxx Sat Sep 7
04:58:20 2002
+++ threads/SGThread.cxx Wed Dec 4 21:29:37 2002
@@ -19,18 +19,20 @@
void
SGThread::set_cancel( cancel_t mode )
{
+ int oldstate;
+
switch (mode)
{
case CANCEL_DISABLE:
- pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, 0 );
+ pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, &oldstate );
break;
case CANCEL_DEFERRED:
- pthread_setcanceltype( PTHREAD_CANCEL_DEFERRED, 0 );
- pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, 0 );
+ pthread_setcanceltype( PTHREAD_CANCEL_DEFERRED, &oldstate );
+ pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, &oldstate );
break;
case CANCEL_IMMEDIATE:
- pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS, 0 );
- pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, 0 );
+ pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate );
+ pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, &oldstate );
break;
default:
break;
diff -Nuar /home/erik/src/CVS/fgfs/SimGear/simgear/threads/SGThread.hxx
threads/SGThread.hxx
--- /home/erik/src/CVS/fgfs/SimGear/simgear/threads/SGThread.hxx Sat Sep 7
04:58:20 2002
+++ threads/SGThread.hxx Thu Dec 5 10:58:44 2002
@@ -26,6 +26,7 @@
#include <simgear/compiler.h>
#include <pthread.h>
+#include <signal.h> // pthread_kill
#if defined ( SG_HAVE_STD_INCLUDES )
# include <cassert>
# include <cerrno>
@@ -127,6 +128,8 @@
inline
SGThread::~SGThread()
{
+ // Make sure the thread is cancelled at exit.
+ pthread_kill(tid, SIGKILL);
}
inline int
