Date: Tue, 1 Jul 2003 06:26:14 +0800 From: "David Xu" <davidxu@freebsd.org> To: "xiong jinshan" <xiongjinshan@yahoo.com>, <deischen@freebsd.org> Cc: threads@freebsd.org Subject: Re: About the kse signal process Message-ID: <000701c33f56$9fc98f70$0701a8c0@tiger> References: <20030630154618.93274.qmail@web80511.mail.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
----- Original Message -----=20 From: "xiong jinshan" <xiongjinshan@yahoo.com> To: <deischen@freebsd.org> Cc: <threads@freebsd.org> Sent: Monday, June 30, 2003 11:46 PM Subject: Re: About the kse signal process >=20 > --- Daniel Eischen <eischen@vigrid.com> 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 <stdio.h> > > > #include <signal.h> > > > #include <pthread.h> > > >=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 ?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000701c33f56$9fc98f70$0701a8c0>