From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32450 invoked by alias); 11 Apr 2008 16:19:02 -0000 Received: (qmail 32440 invoked by uid 22791); 11 Apr 2008 16:19:01 -0000 X-Spam-Check-By: sourceware.org Received: from host0.dyn.jankratochvil.net (HELO host0.dyn.jankratochvil.net) (89.250.240.59) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 11 Apr 2008 16:18:44 +0000 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.2/8.14.1) with ESMTP id m3BGIQ65032555; Fri, 11 Apr 2008 18:18:27 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.2/8.14.2/Submit) id m3BGIP3W032554; Fri, 11 Apr 2008 18:18:25 +0200 Date: Fri, 11 Apr 2008 17:46:00 -0000 From: Jan Kratochvil To: Roland McGrath Cc: Daniel Jacobowitz , Doug Evans , GDB Patches , mark.kettenis@xs4all.nl Subject: Re: [patch] Fix Linux attach to signalled/stopped processes Message-ID: <20080411161824.GA4183@host0.dyn.jankratochvil.net> References: <20080401223012.GA14076@host0.dyn.jankratochvil.net> <20080410153735.GD21662@caradoc.them.org> <20080410154839.GA5375@host0.dyn.jankratochvil.net> <20080410231205.2DBFD26F992@magilla.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080410231205.2DBFD26F992@magilla.localdomain> User-Agent: Mutt/1.5.17 (2007-11-01) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-04/txt/msg00221.txt.bz2 On Fri, 11 Apr 2008 01:12:05 +0200, Roland McGrath wrote: > > As the shell already did WAITPID on the process and ate the SIGSTOP > > notification so there is no other notification left there for GDB. > > A process already stopped does not generate another SIGSTOP during > > PTRACE_ATTACH as signals never count. > > To be pedantic about it: a SIGSTOP is generated, but causes no wakeup or > delivery for ptrace to see (because it's already stopped). You can see > the SIGSTOP pending in /proc/pid/status. Generating a SIGCONT clears > any pending stop signals, so normally it's as if it never existed. But, > I think if you were to do PTRACE_CONT,pid,0,0 you would make it wake up, > dequeue the new SIGSTOP and then report to you for wait/SIGCHLD. And > since PTRACE_CONT would give ESRCH if it weren't stopped yet, you might > be able to do PTRACE_ATTACH;PTRACE_CONT;wait reliably. But don't hold > me to it. There is a race if: * inferior was not stopped (a regular running process) * PTRACE_ATTACH * sleep a bit * PTRACE_CONT - Here we do not get ESRCH but it behaves as a regular continuation of the inferior - as we would do PTRACE_ATTACH;waitpid;PTRACE_CONT. nonESRCH does not mean the inferior was stopped before PTRACE_ATTACH. So IMO we must first check if the inferior is stopped in `/proc/PID/status' which is already racy in respect to later PTRACE_ATTACH and the other ops. Regards, Jan