From 2ae1ef0d505fb18156bbc5ca11e25ae922cd0383 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Thu, 30 May 2013 19:54:27 +0200 Subject: [PATCH] Messy hack to kill busy child processes on exit. --- src/shared.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/shared.py b/src/shared.py index 850c84f3..2edaf616 100644 --- a/src/shared.py +++ b/src/shared.py @@ -7,6 +7,7 @@ import highlevelcrypto import Queue import pickle import os +import signal myECCryptorObjects = {} MyECSubscriptionCryptorObjects = {} @@ -173,12 +174,18 @@ def doCleanShutdown(): print 'Finished flushing inventory.' printLock.release() - + if safeConfigGetBoolean('bitmessagesettings','daemon'): printLock.acquire() print 'Done.' printLock.release() os._exit(0) + + #Messy hack to kill child processes immediately. May not work on all platforms. + try: + os.killpg(os.getpgid(os.getpid()), signal.SIGTERM) + except: + os.kill(os.getpid(), signal.SIGTERM) #Wen you want to command a sendDataThread to do something, like shutdown or send some data, this function puts your data into the queues for each of the sendDataThreads. The sendDataThreads are responsible for putting their queue into (and out of) the sendDataQueues list. def broadcastToSendDataQueues(data): @@ -197,4 +204,4 @@ def flushInventory(): sqlReturnQueue.get() del inventory[hash] sqlSubmitQueue.put('commit') - sqlLock.release() \ No newline at end of file + sqlLock.release()