X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Message-ID: <4FFD7007.4080701@sister-shadow.de> Date: Wed, 11 Jul 2012 14:22:31 +0200 From: Otto Meta User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: 1.7.15-1: pthread_cancel and pthread_kill not working as expected References: <4FAAAE25 DOT 40204 AT sister-shadow DOT de> <4FB62304 DOT 2000100 AT sister-shadow DOT de> <4FBA1846 DOT 6020005 AT sister-shadow DOT de> <20120521104717 DOT GC7763 AT calimero DOT vinschen DOT de> <4FBA38A5 DOT 5030408 AT sister-shadow DOT de> <20120522110238 DOT GC15843 AT calimero DOT vinschen DOT de> In-Reply-To: <20120522110238.GC15843@calimero.vinschen.de> Content-Type: multipart/mixed; boundary="------------020107030407000406050501" X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 --------------020107030407000406050501 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2012-05-22 13:02, Corinna Vinschen wrote: [...] >> Testcase signal/kill: >> Signals may or may not reach the correct thread with 1.7.12-1 and newer. > > Confirmed. I think the reason is that we only have a single event to > signal that a POSIX signal arrived instead of a per-thread event, but > I'm not sure. This is cgf's domain so I leave it at that for now. Is this problem still in the queue? The newest snapshot yields the same results as before. $ uname -srv CYGWIN_NT-6.1-WOW64 1.7.16s(0.261/5/3) 20120708 00:52:15 I attached a slightly simpler version of the testcase. Test output: Sending SIGUSR1 to thread 2 Thread 0 encountered an error: Interrupted system call Sending SIGUSR1 to thread 1 Thread 1 executes signal handler Thread 1 encountered an error: Interrupted system call Sending SIGUSR1 to thread 0 Thread 2 executes signal handler Thread 2 encountered an error: Interrupted system call Otto --------------020107030407000406050501 Content-Type: text/x-csrc; name="testcase_signal.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="testcase_signal.c" #include #include #include #include #include #include #include pthread_t tids[3]; static void* simplethread(void *arg) { int *intptr = (int*)arg; pthread_t self = pthread_self(); fprintf(stderr, "Thread %i starting (%p)\n", *intptr, self); while (1) { if (pause() != 0) { fprintf(stderr, "Thread %i encountered an error: %s (%p)\n", *intptr, strerror(errno), self); } else { fprintf(stderr, "Thread %i woke up just fine\n", *intptr); } } return NULL; } static void sigusr1_handler(int signal __attribute((unused))) { pthread_t self = pthread_self(); // Search for thread number int tnum = 0; while (tnum < 3) { if (tids[tnum] == self) { break; } tnum++; } fprintf(stderr, "Thread %i executes signal handler (%p)\n", tnum, self); } static void install_handler(void) { struct sigaction act; act.sa_handler = &sigusr1_handler; sigemptyset(&(act.sa_mask)); act.sa_flags = 0; // Install signal handler if (sigaction(SIGUSR1, &act, NULL) != 0) { fprintf(stderr, "Can't set signal handler: %s\n", strerror(errno)); exit(1); } // Make sure SIGUSR1 is not blocked sigset_t sset; sigemptyset(&sset); sigaddset(&sset, SIGUSR1); if (sigprocmask(SIG_UNBLOCK, &sset, NULL) != 0) { fprintf(stderr, "Can't unblock SIGUSR1: %s\n", strerror(errno)); } } int main() { fprintf(stderr, "Testing pthread_kill()\n\n"); int i; int result; install_handler(); // Create threads for (i=0; i<3; i++) { int *intptr = (int*)malloc(sizeof(int)); *intptr = i; result = pthread_create(tids+i, NULL, &simplethread, intptr); if (result != 0) { fprintf(stderr, "Can't create thread: %s\n", strerror(result)); return 1; } } sleep(1); install_handler(); fprintf(stderr, "\n"); // Poke all threads for (i=2; i>=0; i--) { fprintf(stderr, "Sending SIGUSR1 to thread %i (%p)\n", i, tids[i]); result = pthread_kill(tids[i], SIGUSR1); if (result != 0) { fprintf(stderr, "Error during pthread_kill: %s\n", strerror(result)); } sleep(1); fprintf(stderr, "\n"); } return 0; } --------------020107030407000406050501 Content-Type: text/plain; charset=us-ascii -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --------------020107030407000406050501--