From owner-freebsd-threads@FreeBSD.ORG Mon Jun 30 15:23:07 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 05FE237B407; Mon, 30 Jun 2003 15:23:07 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7120F43FB1; Mon, 30 Jun 2003 15:23:06 -0700 (PDT) (envelope-from davidxu@freebsd.org) Received: from tiger (davidxu@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with SMTP id h5UMN3Up012000; Mon, 30 Jun 2003 15:23:04 -0700 (PDT) (envelope-from davidxu@freebsd.org) Message-ID: <000701c33f56$9fc98f70$0701a8c0@tiger> From: "David Xu" To: "xiong jinshan" , References: <20030630154618.93274.qmail@web80511.mail.yahoo.com> Date: Tue, 1 Jul 2003 06:26:14 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 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: David Xu List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jun 2003 22:23:07 -0000 ----- Original Message -----=20 From: "xiong jinshan" To: Cc: Sent: Monday, June 30, 2003 11:46 PM Subject: Re: About the kse signal process >=20 > --- Daniel Eischen wrote: > > On Mon, 30 Jun 2003, xiong jinshan wrote: > >=20 > > > 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. > >=20 > > Yes, only thr_func() should receive the alarm. > This is the issue. Nothing printed on the console when > I sent the signal SIGALRM, it meant that none of the > thread received this signal. >=20 > >=20 > > >=20 > > > Reguards, > > > JinShan > > >=20 > > > Ps: c code: > > >=20 > > > /* vi: set ts=3D4 sw=3D4 expandtab: */ > > > #include > > > #include > > > #include > > >=20 > > > void sigalrm_handler(int signo) > > > { > > > if(signo !=3D SIGALRM) > > > abort(); > > >=20 > > > printf("Received sig alarm!\n"); > > > return; > > > } > > >=20 > > > void thr_func(void) > > > { > > > sigset_t mask; > > > struct sigaction sa; > > >=20 > > > sigemptyset(&mask); > > > sigaddset(&mask, SIGALRM); > > > pthread_sigmask(SIG_UNBLOCK, &mask, NULL); > > >=20 > > > memset(&sa, 0, sizeof(struct sigaction)); > > > sa.sa_handler =3D sigalrm_handler; > > > sigaction(SIGALRM, &sa, NULL); > > >=20 > > > while(1); > > > } > > >=20 > > > main() > > > { > > > int err; > > > pthread_t pth; > > > sigset_t mask; > > >=20 > > > sigfillset(&mask); > > > sigprocmask(SIG_BLOCK, &mask, NULL); > > >=20 > > > err =3D pthread_create(&pth, NULL, thr_func, > > NULL); > > > if(err < 0) { > > > perror("pthread_create!\n"); > > > return -1; > > > } > > >=20 > > > while(1); > >=20 > > --=20 > > Dan Eischen > >=20 >=20 >=20 Missing alarm() call ?