summaryrefslogtreecommitdiff
path: root/sanei/sanei_thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'sanei/sanei_thread.c')
-rw-r--r--sanei/sanei_thread.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sanei/sanei_thread.c b/sanei/sanei_thread.c
index fd58af2..8db4a21 100644
--- a/sanei/sanei_thread.c
+++ b/sanei/sanei_thread.c
@@ -512,11 +512,15 @@ sanei_thread_waitpid( SANE_Pid pid, int *status )
DBG(2, "* result = %d (%p)\n", stat, (void*)status );
result = pid;
}
- /* call detach in any case to make sure that the thread resources
- * will be freed, when the thread has terminated
- */
- DBG(2, "* detaching thread(%ld)\n", pid );
- pthread_detach((pthread_t)pid);
+ if ( EDEADLK == rc ) {
+ if ( (pthread_t)pid != pthread_self() ) {
+ /* call detach in any case to make sure that the thread resources
+ * will be freed, when the thread has terminated
+ */
+ DBG(2, "* detaching thread(%ld)\n", pid );
+ pthread_detach((pthread_t)pid);
+ }
+ }
if (status)
*status = stat;