On Fri, 19 Nov 1999, Scott Hess wrote:

> Daniel Eischen <[EMAIL PROTECTED]> wrote:
> >Scott Hess mailto:[EMAIL PROTECTED] 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
[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to