Long story short: when I call exit() from a process started from QtConcurrent::run() it enters an infinite loop here:
0 pthread_cond_wait pthread_cond_wait.S 162 0x00007ffff609459c
1 wait qwaitcondition_unix.cpp 87 0x00007ffff6a27a7b
3 QThreadPoolPrivate::waitForDone qthreadpool.cpp 295 0x00007ffff6a1c808
4 QThreadPool::~QThreadPool qthreadpool.cpp 428 0x00007ffff6a1cfff
5 QGlobalStaticDeleter<QThreadPool>::~QGlobalStaticDeleter qglobal.h 1796 0x00007ffff6a1d695
6 __run_exit_handlers exit.c 78 0x00007ffff55ad045
7 exit exit.c 100 0x00007ffff55ad095
8 fsElement::fsElement fselement.cpp 41 0x000000000040b266
9 fsElement::populateDirList fselement.cpp 65 0x000000000040b70b
10 fsElement::findFilesAndDirs fselement.cpp 120 0x000000000040be77
11 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
12 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
13 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
14 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
15 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
16 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
17 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
18 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
19 QtConcurrent::VoidStoredMemberFunctionPointerCall0<void, fsElement>::runFunctor qtconcurrentstoredfunctioncall.h 216 0x000000000040adc4
20 QtConcurrent::RunFunctionTask<void>::run qtconcurrentrunbase.h 120 0x000000000040a396
21 QThreadPoolThread::run qthreadpool.cpp 106 0x00007ffff6a1ca4f
22 QThreadPrivate::start qthread_unix.cpp 248 0x00007ffff6a26a25
23 start_thread pthread_create.c 301 0x00007ffff608fc1a
24 clone clone.S 115 0x00007ffff5649a9d
0 pthread_cond_wait pthread_cond_wait.S 162 0x00007ffff609459c
1 wait qwaitcondition_unix.cpp 87 0x00007ffff6a27a7b
2 QWaitCondition::wait qwaitcondition_unix.cpp 159 0x00007ffff6a27a7b
3 QThreadPoolPrivate::waitForDone qthreadpool.cpp 295 0x00007ffff6a1c808
4 QThreadPool::~QThreadPool qthreadpool.cpp 428 0x00007ffff6a1cfff
5 QGlobalStaticDeleter<QThreadPool>::~QGlobalStaticDeleter qglobal.h 1796 0x00007ffff6a1d695
6 __run_exit_handlers exit.c 78 0x00007ffff55ad045
7 exit exit.c 100 0x00007ffff55ad095
8 fsElement::fsElement fselement.cpp 41 0x000000000040b266
9 fsElement::populateDirList fselement.cpp 65 0x000000000040b70b
10 fsElement::findFilesAndDirs fselement.cpp 120 0x000000000040be77
11 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
12 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
13 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
14 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
15 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
16 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
17 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
18 fsElement::findFilesAndDirs fselement.cpp 122 0x000000000040be9c
19 QtConcurrent::VoidStoredMemberFunctionPointerCall0<void, fsElement>::runFunctor qtconcurrentstoredfunctioncall.h 216 0x000000000040adc4
20 QtConcurrent::RunFunctionTask<void>::run qtconcurrentrunbase.h 120 0x000000000040a396
21 QThreadPoolThread::run qthreadpool.cpp 106 0x00007ffff6a1ca4f
22 QThreadPrivate::start qthread_unix.cpp 248 0x00007ffff6a26a25
23 start_thread pthread_create.c 301 0x00007ffff608fc1a
24 clone clone.S 115 0x00007ffff5649a9d
To copy to clipboard, switch view to plain text mode
So I guess I shouldn't use exit() in this fashion. Is there some other way to exit a thread in this situation?
Bonus, longer question: I just want a way to perform some heavy i/o work and still keep the GUI up to date and responsive (I'm writing a file searching app as an exercise). Doing it in a seperate thread worked quite well, but I'd also like to have the ability to pause and cancel the work. Is threading the best way to do it? What should I do to do it right? QThread? QRunnable? Or is QtConcurrent the best way?
Bookmarks