Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 May 2000 01:56:29 -0700 (PDT)
From:      hwc@openfind.com.tw
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/18559: pthread_self and signal handler (SIGPIPE)
Message-ID:  <20000515085629.8023E37B52A@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         18559
>Category:       misc
>Synopsis:       pthread_self and signal handler (SIGPIPE)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          wish
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 15 02:00:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Huang Wei-Chen
>Release:        FreeBSD 4.0
>Organization:
openfind (http://www.openfind.com)
>Environment:
FreeBSD sable1.iis.sinica.edu.tw 4.0-STABLE FreeBSD 4.0-STABLE #1: Fri May 12 11:19:20 CST 2000     root@sable1.iis.
sinica.edu.tw:/usr/src/sys/compile/SABLE1_MP  i386



>Description:
I don't knwow is this a bug....


In the thread before use
   send(...)
I'v use
   signal(SIGPIPE,sig_handler);
In sig_handler,
   fprintf(g_log,"%d\t",pthread_self())

but I found, in sig_handler,
   the thread_self return main's thread_id,
   not the thread that use "send" ...


I'v use this code in linux,
in sig_handler,
   the thread_self return "send" thread id, as I'm assumed..

Is freebsd normal ?
I'v traced 
	/usr/src/lib/libc_r/uthread_sig.c
-rw-r--r--  1 root  wheel  20777   3/22 09:19 uthread_sig.c
when SIGPIPE occurs, in 
   _thread_sig_handler(int sig, int code, ucontext_t * scp)
the 
   _thread_run (global variable, pthread_self?)
is the the "send" thread,
but the
   _thread_sig_handle(sig, scp);
return the main thread

I'v modified some code in _thread_sig_handle,
	/usr/src/lib/libc_r/uthread_sig.c, line 323
	
                if ((_thread_sigact[sig - 1].sa_handler == SIG_IGN) ||
                    (_thread_sigact[sig - 1].sa_handler == SIG_DFL))
                        handler_installed = 0;
                else
                        handler_installed = 1;
/**** my code added begin***/
                if (sig==SIGPIPE && handler_installed==1  &&   !sigismember(&_thread_run->sigmask, sig))
                         signaled_thread = _thread_run;
                else
/**** my code end***/
                for (pthread = TAILQ_FIRST(&_waitingq);
                    pthread != NULL; pthread = pthread_next) {
                        /*
                         * Grab the next thread before possibly destroying
                         * the link entry.
                         */
                        pthread_next = TAILQ_NEXT(pthread, pqe);

                               if (sig==SIGPIPE && handler_installed==1)
                                {
                                    if (!sigismember(&_thread_run->sigmask, sig)) {
                                                signaled_thread = _thread_run;

Seems fine......
I don't know will it produce side effect?




>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000515085629.8023E37B52A>