From owner-freebsd-threads@FreeBSD.ORG Mon Jun 30 06:37:51 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1895A37B401 for ; Mon, 30 Jun 2003 06:37:51 -0700 (PDT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7791B43FBF for ; Mon, 30 Jun 2003 06:37:50 -0700 (PDT) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.8/8.12.1) with ESMTP id h5UDbnAI025243; Mon, 30 Jun 2003 09:37:49 -0400 (EDT) Date: Mon, 30 Jun 2003 09:37:49 -0400 (EDT) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: xiong jinshan In-Reply-To: <20030630080920.82179.qmail@web80504.mail.yahoo.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: threads@freebsd.org Subject: Re: About the kse signal process X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: deischen@freebsd.org List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jun 2003 13:37:51 -0000 On Mon, 30 Jun 2003, xiong jinshan wrote: > Hi, > I am wondering that the following piece of code > can't work with the unix semantics. I tested it with > 5.1 release and i386 arch. By unix sementics, if I > send the SIGALRM to this running programme, it should > be received by the thr_func() only, and print a prompt > msg on the console. Yes, only thr_func() should receive the alarm. > > Reguards, > JinShan > > Ps: c code: > > /* vi: set ts=4 sw=4 expandtab: */ > #include > #include > #include > > void sigalrm_handler(int signo) > { > if(signo != SIGALRM) > abort(); > > printf("Received sig alarm!\n"); > return; > } > > void thr_func(void) > { > sigset_t mask; > struct sigaction sa; > > sigemptyset(&mask); > sigaddset(&mask, SIGALRM); > pthread_sigmask(SIG_UNBLOCK, &mask, NULL); > > memset(&sa, 0, sizeof(struct sigaction)); > sa.sa_handler = sigalrm_handler; > sigaction(SIGALRM, &sa, NULL); > > while(1); > } > > main() > { > int err; > pthread_t pth; > sigset_t mask; > > sigfillset(&mask); > sigprocmask(SIG_BLOCK, &mask, NULL); > > err = pthread_create(&pth, NULL, thr_func, NULL); > if(err < 0) { > perror("pthread_create!\n"); > return -1; > } > > while(1); -- Dan Eischen