changeset 2338:3dacb1001537 time-frequency-boxes

Don't wait forever for this lock
author Chris Cannam
date Fri, 04 Oct 2019 16:04:55 +0100
parents 2721030c939f
children 1e77e4ee27f5
files main/main.cpp
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/main/main.cpp	Wed Sep 25 11:13:16 2019 +0100
+++ b/main/main.cpp	Fri Oct 04 16:04:55 2019 +0100
@@ -188,12 +188,15 @@
     // Avoid this happening more than once across threads
 
     cerr << "signalHandler: cleaning up and exiting" << endl;
-    cleanupMutex.lock();
-    if (!cleanedUp) {
-        TempDirectory::getInstance()->cleanup();
-        cleanedUp = true;
+
+    if (cleanupMutex.tryLock(5000)) {
+        if (!cleanedUp) {
+            TempDirectory::getInstance()->cleanup();
+            cleanedUp = true;
+        }
+        cleanupMutex.unlock();
     }
-    cleanupMutex.unlock();
+    
     exit(0);
 }