From owner-freebsd-questions@FreeBSD.ORG Tue May 19 01:29:34 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 10DBB1065670 for ; Tue, 19 May 2009 01:29:34 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from asmtpout013.mac.com (asmtpout013.mac.com [17.148.16.88]) by mx1.freebsd.org (Postfix) with ESMTP id F0DBA8FC0C for ; Tue, 19 May 2009 01:29:33 +0000 (UTC) (envelope-from cswiger@mac.com) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Received: from cswiger1.apple.com ([17.227.140.124]) by asmtp013.mac.com (Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008; 32bit)) with ESMTPSA id <0KJV00EKEAT9PO10@asmtp013.mac.com> for freebsd-questions@freebsd.org; Mon, 18 May 2009 18:29:33 -0700 (PDT) Message-id: <45A2F58C-968F-47F7-90E3-1F84F0B122C9@mac.com> From: Chuck Swiger To: Peter Steele In-reply-to: <25097232.1021242693162151.JavaMail.HALO$@halo> Date: Mon, 18 May 2009 18:29:33 -0700 References: <25097232.1021242693162151.JavaMail.HALO$@halo> X-Mailer: Apple Mail (2.935.3) Cc: #freebsd-questions Subject: Re: Why would a kill -2 not work? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 01:29:34 -0000 On May 18, 2009, at 5:32 PM, Peter Steele wrote: > No, I'm not sending a signal within a signal. The signal handler is > this: > > pthread_mutex_lock(&keep_running_mutex); > KEEP_RUNNING = 0; > pthread_cond_signal(&keep_running_cond); > pthread_mutex_unlock(&keep_running_mutex); > > This works fine, but at some point it seems to stop working. The app > just continues to run as if it never received the -2 signal. We have > to use a kill -9 to kill it, which we want to avoid because this > prevents our shutdown code from executing. The pthread_* calls you are making aren't listed as being safe to run within the context of a signal handler, and could cause a thread waiting on that condition to be unblocked and start running. Please see earlier comments about mixing threads and signal handlers. -- -Chuck