Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Nov 1999 13:43:29 -0500 (EST)
From:      Daniel Eischen <eischen@vigrid.com>
To:        Scott Hess <scott@avantgo.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: EINTR problems with multithreaded programs.
Message-ID:  <Pine.SUN.3.91.991119133538.4368A-100000@pcnet1.pcnet.com>
In-Reply-To: <03e501bf32ba$76d83550$1e80000a@avantgo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 19 Nov 1999, Scott Hess wrote:

> Daniel Eischen <eischen@vigrid.com> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SUN.3.91.991119133538.4368A-100000>