X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Artem Alimarin Subject: =?utf-8?b?cGhyZWFkX2pvaW4=?= problem Date: Thu, 16 Mar 2006 10:41:03 +0000 (UTC) Lines: 87 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Hi, I have a problem with the small program attached below that does not do what I expect. The program prints: cancelling cleanup cancelled, joining exception last chance thread is about to return pthread_join hangs infinitely. I expect the join to resume because the thread has exitted. What is a problem? The cygwin version info: $ uname -a CYGWIN_NT-5.2-WOW64 artem64 1.5.19(0.150/4/2) 2006-01-20 13:28 i686 Cygwin The program compiler as: $ g++ -o th.exe th.cpp Thanks in advance, Artem Alimarine //===================================================== #include #include #include #include using namespace std; class exit_exception {}; void cleanup_routine(void*) { cout << "cleanup\n"; throw exit_exception(); } void foo() { try { sleep(100); } catch(const exit_exception&) { cout << "exception\n"; throw; } } void* thread_routine(void*) { try { pthread_cleanup_push(cleanup_routine, NULL); foo(); pthread_cleanup_pop(0); } catch(const exit_exception&) { cout << "last chance\n"; } cout << "thread is about to return\n"; return NULL; } int main() { pthread_t the_handle; int res; res = pthread_create(&the_handle, NULL, thread_routine, NULL); assert(res == 0); sleep(1); cout << "cancelling\n"; res = pthread_cancel(the_handle); assert(res == 0); cout << "cancelled, joining\n"; res = pthread_join(the_handle, NULL); assert(res == 0); cout << "joined\n"; pthread_detach(the_handle); } //===================================================== -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/