From owner-freebsd-threads@FreeBSD.ORG Mon Jun 21 19:20:29 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F0D0916A4CE for ; Mon, 21 Jun 2004 19:20:29 +0000 (GMT) Received: from mail.mcneil.com (rrcs-west-24-199-45-54.biz.rr.com [24.199.45.54]) by mx1.FreeBSD.org (Postfix) with ESMTP id CEAE943D48 for ; Mon, 21 Jun 2004 19:20:27 +0000 (GMT) (envelope-from sean@mcneil.com) Received: from localhost (localhost.mcneil.com [127.0.0.1]) by mail.mcneil.com (Postfix) with ESMTP id 390E9FD076; Mon, 21 Jun 2004 12:20:27 -0700 (PDT) Received: from mail.mcneil.com ([127.0.0.1]) by localhost (server.mcneil.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 84820-07; Mon, 21 Jun 2004 12:20:26 -0700 (PDT) Received: from [24.199.45.54] (mcneil.com [24.199.45.54]) by mail.mcneil.com (Postfix) with ESMTP id C5813FD067; Mon, 21 Jun 2004 12:20:26 -0700 (PDT) From: Sean McNeil To: Daniel Eischen In-Reply-To: References: Content-Type: text/plain Message-Id: <1087845626.85957.1.camel@server.mcneil.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 21 Jun 2004 12:20:26 -0700 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mcneil.com cc: freebsd-threads@freebsd.org Subject: Re: kill(pid,0) sends a signal or not? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jun 2004 19:20:30 -0000 On Mon, 2004-06-21 at 07:36, Daniel Eischen wrote: > On Sun, 20 Jun 2004, Sean McNeil wrote: > > > I'm trying to trace down an issue with kse threads and firefox. There > > is an odd "trick" I haven't seen before: > > > > // kill(pid,0) is a neat trick to check if a > > // process exists > > if (kill(pid, 0) == 0 || errno != ESRCH) > > > > Does this really work? It is kind of odd that it I appear to get a > > signal (if the traceback is accurate) with the signal set to 0: > > > > #10 0x0000000202bc7a80 in thr_resume_wrapper (sig=0, siginfo=0x4, > > ucp=0x7fffffffd4c0) at /usr/src/lib/libpthread/thread/thr_kern.c:1112 > > > > This later causes a sig 11 and the program core dumps. > > > > Any info on how threads are suppose to behave when a process does a > > kill(pid,0) would be greatly appreciated. > > kill(pid, 0) shouldn't result in a signal. libpthread doesn't do > anything with kill() and the kernel shouldn't cause a signal for 0 > either. What does ktrace show? It wasn't generating a sig 0. What I was seeing was the inner workings of the threads where a "sig" variable was set to 0, but the actual signal was 11. Everything is working as designed as far as I can tell.