From owner-freebsd-current@FreeBSD.ORG Sat May 8 11:50:41 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9C42F106564A for ; Sat, 8 May 2010 11:50:41 +0000 (UTC) (envelope-from gljennjohn@googlemail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 2A3AF8FC19 for ; Sat, 8 May 2010 11:50:40 +0000 (UTC) Received: by fxm15 with SMTP id 15so1527051fxm.13 for ; Sat, 08 May 2010 04:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:reply-to:x-mailer:mime-version :content-type:content-transfer-encoding; bh=gn05/r/dUFNltktNRwtGOtNwdsNYvD80mxpRh+DtDow=; b=mu/dxjxYwa5TrcCuPBrcoXrMcrPHGe+LQhEyxfm+djNOYqoMwNyfdtvOSn21vIatGz wT8GIyEFL0a4gnMvgzDUeQvL/FtTPER/crj1lS1IcuzLgYjswr0suNaT+cBcEbkSb9yy Ft+5nFOK1sEjnbntQrQ98XFPy8gCtO49+RUQU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:reply-to :x-mailer:mime-version:content-type:content-transfer-encoding; b=I7Ty+qQy6l/BTFyaRNYDajbR+mnEC5LX2NgBOlNdQ9EFT+YuPJ+6Oz05g2pHQYlQfc 99159O7BQOcNXBIc7uZXDaCdk5upsiuxKAMTMkZK6xNGdP4D1TPHRftIRNWTSmBcL30G mt9bdy72/HB/y0uf/NyCHKK1jS5SCEXFLrgqA= Received: by 10.102.193.9 with SMTP id q9mr697900muf.11.1273319433904; Sat, 08 May 2010 04:50:33 -0700 (PDT) Received: from ernst.jennejohn.org (p57AE25C1.dip0.t-ipconnect.de [87.174.37.193]) by mx.google.com with ESMTPS id n7sm12221749mue.15.2010.05.08.04.50.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 08 May 2010 04:50:33 -0700 (PDT) Date: Sat, 8 May 2010 13:50:31 +0200 From: Gary Jennejohn To: Ben Widawsky Message-ID: <20100508135031.00fcd71e@ernst.jennejohn.org> In-Reply-To: References: X-Mailer: Claws Mail 3.7.5 (GTK+ 2.18.7; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org Subject: Re: PT_ATTACH resumes suspended process X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: gljennjohn@googlemail.com List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 May 2010 11:50:41 -0000 On Fri, 7 May 2010 13:52:15 -0700 Ben Widawsky wrote: > If a debugger attaches to a suspended process, the process will be > resumed, and backgrounded. This seems like the incorrect behavior to me > based what I read in the man page. "The tracing process will see the > newly-traced process stop and may then control it as if it had been > traced all along." > > The behavior exhibited in FreeBSD is that the process is resumed, and we > will not reach ptracestop() until the next debugger command comes in. > [snip] Looking at the sendsig label in sys_process.c:kern_ptrace() makes it clear what's happening - in your testing the process was already stopped so the code sets td_xsig to SIGSTOP and wakes it up to send it the signal. But td_xsig doesn't seem to be used anywhere to set pending signals. Maybe I missed the place where that happens. The assumption seems to be that a process being traced will only be stopped if the debugger is already attached and that any signals being sent to it are coming from the debugger itself. This assumption is wrong if the process being attached to was already stopped. It seems to me that checking for req == PT_ATTACH when the process is already stopped and doing a break; in that case might be a solution. -- Gary Jennejohn