(svn r12257) [NoAI] -Fix: flush stdout and stderr when killing a thread, avoids data-loss ;) noai
authortruebrain
Mon, 25 Feb 2008 16:29:48 +0000
branchnoai
changeset 9768 28dfd4da5d62
parent 9767 a937441fecf1
child 9769 015b6674c8ad
(svn r12257) [NoAI] -Fix: flush stdout and stderr when killing a thread, avoids data-loss ;)
src/ai/ai_threads.cpp
--- a/src/ai/ai_threads.cpp	Mon Feb 25 16:26:30 2008 +0000
+++ b/src/ai/ai_threads.cpp	Mon Feb 25 16:29:48 2008 +0000
@@ -317,6 +317,12 @@
 	/*virtual*/ ~AIThread_MT()
 	{
 		DEBUG(ai, 3, "-AIThread_MT(%d) from thr %u", this->fiber_id, ThreadObject::CurrentId());
+
+		/* Flush stdout and stderr, as killing the thread doesn't allow the thread
+		 *  to do that (in case there still is something to print) */
+		fflush(stdout);
+		fflush(stderr);
+
 		this->evt_go.Detach();
 	}