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 X-T2-Posting-ID: dCnToGxhL58ot4EWY8b+QGwMembwLoz1X2yB7MdtIiA= Date: Tue, 23 Aug 2005 22:51:44 +0200 From: Samuel Thibault To: cygwin AT cygwin DOT com Subject: threads and signals Message-ID: <20050823205144.GE6716@bouh.ens-lyon.fr> Mail-Followup-To: Samuel Thibault , cygwin AT cygwin DOT com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="uAKRQypu60I7Lcqm" Content-Disposition: inline User-Agent: Mutt/1.5.9i-nntp --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, The attached program doesn't work as expected: if I run it and try to kill it (-15), nothing seem happens. I if comment out pthread_sigmask(), it does work as expected: the handler is called, and threads are interrupted. What's more: if I move pthread_sigmask() after the pause() call in the foo() function, killing works twice, but no more. It seems like signal masks are not handled per-thread, and the source code for pthread_sigmask seems to confirm that. This can pose problem with signal distribution for some programs which require posix semantic here. Regards, Samuel --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="test.c" #include #include #include #include #include void *foo(void* bar) { sigset_t blocked; sigemptyset(&blocked); sigaddset(&blocked,SIGTERM); pthread_sigmask(SIG_BLOCK,&blocked, NULL); while(1) { pause(); fprintf(stderr,"thread %d awaken\n",(int)bar); } } void handler(int foo) { fprintf(stderr,"foo %d\n",foo); } void setsig(int foo) { struct sigaction action; memset(&action, 0, sizeof(action)); sigemptyset(&action.sa_mask); action.sa_handler = handler; if (sigaction(foo, &action, NULL) == -1) perror("sigaction"); } int main(int argc, char*argv[]) { pthread_t t; setsig(SIGTERM); pthread_create(&t,NULL,foo,0); while (1) { pause(); fprintf(stderr,"main awaken"); } } --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=us-ascii -- 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/ --uAKRQypu60I7Lcqm--