This is the mail archive of the cygwin mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Using cygwin 1.5.11-1 or snapshot 2004-Oct-10 on XP Pro SP2, a thread blocked at a write() to a full pipe does not appear cancellable with pthread_cancel(). "cygcheck.out" is attached. I'm guessing that POSIX specifies that write() is supposed to be a cancellation point, but I do not have a copy of the spec (any pointers would be appreciated). I'm guessing this based on (1) the man pages in Solaris ('man cancellation'), and (2) the fact that it works as I expect on the Solaris 9 and Redhat 9.0 systems I've tried. My test code appears at the end of this e-mail. Searching with google and searching the cygwin mailing list with keywords like "pthread_cancel", "thread cancellation", etc., I was unable to find much relevant information. I did find some old messages claiming that pthreads were not yet fully implemented in cygwin. If pthread_cancel() is known to be incomplete or if this is a known bug, then I'd appreciate a pointer to the relevant information, and I apologize for the repeat. If I can be of any assistance in resolving this issue, please let me know. However, I'm not yet intelligent enough about cygwin to try a patch. Joel Denny #include <stdlib.h> #include <stdio.h> #include <pthread.h> #include <unistd.h> int aFd[2]; /* Set this large enough to fill the pipe on your system. */ #define I_PIPE_FILL 90000 void * foo( void * dummy ) { int i_byte; /* Use _DISABLE instead to prove that the thread does block on write. */ pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, NULL ); printf( "thread is alive\n" ); fflush( stdout ); for ( i_byte = 0; i_byte < I_PIPE_FILL; ++i_byte ) { write( aFd[1], "0", 1 ); } return NULL; } int main() { pthread_t thread; char a_buf[1]; pipe( aFd ) ) { pthread_create( &thread, NULL, foo, NULL ); /* Wait until thread has enabled/disabled cancellation. */ read( aFd[0], a_buf, 1 ); printf( "Thread created.\n" ); fflush( stdout ); /* Will not cancel write() on full pipe in cygwin. */ pthread_cancel( thread ); printf( "Thread canceled.\n" ); fflush( stdout ); /* Deadlocks here if thread not cancelled. */ pthread_join( thread, NULL ); printf( "Thread joined.\n" ); fflush( stdout ); return 0; }
Attachment:
cygcheck.out
Description: Text document
-- 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/
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |