From owner-freebsd-hackers Fri Nov 19 10:43:32 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from pcnet1.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (Postfix) with ESMTP id 1EAEF14F46 for ; Fri, 19 Nov 1999 10:43:29 -0800 (PST) (envelope-from eischen@vigrid.com) Received: (from eischen@localhost) by pcnet1.pcnet.com (8.8.7/PCNet) id NAA05320; Fri, 19 Nov 1999 13:43:30 -0500 (EST) Date: Fri, 19 Nov 1999 13:43:29 -0500 (EST) From: Daniel Eischen To: Scott Hess Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: EINTR problems with multithreaded programs. In-Reply-To: <03e501bf32ba$76d83550$1e80000a@avantgo.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Fri, 19 Nov 1999, Scott Hess wrote: > Daniel Eischen wrote: > >Scott Hess mailto:scott@avantgo.com wrote: > > > When using -pthread on FreeBSD3.3 to build a multithreaded program, I > find > > > that signals are delivered to all threads (see attached program). > > > Specifically, if multiple threads are in blocking read calls, and a > signal > > > is handled, they will all receive -1 from the read and EINTR in errno. > > > > If you don't want all threads to see the signal(s), then you > > have to block the signal(s) in each thread. > > I've checked further, and found that FreeBSD correctly handles blocking > signals on a per-thread basis. _But_, all threads still get EINTR when a > signal happens while they're in a blocking read. > > I've attached the updated program that shows the correct delivery of the > signals, with system calls still being interrupted. [Sorry about the > attachment, but that seems the safest way to go about getting the file > delivered in usable fashion.] Well, that is wrong and should be fixed. I'll commit a fix to -current this weekend. Here's an untested patch to libc_r/uthread/uthread_sig.c: *** uthread_sig.c.orig Fri Nov 19 13:36:53 1999 --- uthread_sig.c Fri Nov 19 13:38:06 1999 *************** *** 323,330 **** case PS_POLL_WAIT: case PS_SLEEP_WAIT: case PS_SELECT_WAIT: ! if (sig != SIGCHLD || ! _thread_sigact[sig - 1].sa_handler != SIG_DFL) { /* Flag the operation as interrupted: */ pthread->interrupted = 1; --- 323,330 ---- case PS_POLL_WAIT: case PS_SLEEP_WAIT: case PS_SELECT_WAIT: ! if (!sigismember(&pthread->sigmask, sig) && (sig != SIGCHLD || ! _thread_sigact[sig - 1].sa_handler != SIG_DFL)) { /* Flag the operation as interrupted: */ pthread->interrupted = 1; Dan Eischen eischen@vigrid.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message