From owner-freebsd-bugs Mon May 15 2: 0: 7 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id BD49637B5CB for ; Mon, 15 May 2000 02:00:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id CAA69876; Mon, 15 May 2000 02:00:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: by hub.freebsd.org (Postfix, from userid 32767) id 8023E37B52A; Mon, 15 May 2000 01:56:29 -0700 (PDT) Message-Id: <20000515085629.8023E37B52A@hub.freebsd.org> Date: Mon, 15 May 2000 01:56:29 -0700 (PDT) From: hwc@openfind.com.tw To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: misc/18559: pthread_self and signal handler (SIGPIPE) Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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