From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29858 invoked by alias); 24 Sep 2008 12:46:32 -0000 Received: (qmail 29830 invoked by uid 22791); 24 Sep 2008 12:46:30 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 24 Sep 2008 12:45:50 +0000 Received: from Relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 1AF6F41456; Wed, 24 Sep 2008 14:45:48 +0200 (CEST) From: Andreas Schwab To: Roland McGrath Cc: Jan Kratochvil , Doug Evans , GDB Patches , mark.kettenis@xs4all.nl Subject: Re: [patch] Fix Linux attach to signalled/stopped processes References: <20080401223012.GA14076@host0.dyn.jankratochvil.net> <20080410153735.GD21662@caradoc.them.org> <20080410154839.GA5375@host0.dyn.jankratochvil.net> <20080410231205.2DBFD26F992@magilla.localdomain> <20080411161824.GA4183@host0.dyn.jankratochvil.net> <20080412000155.7F07A26FA5E@magilla.localdomain> <20080414143448.GA32227@caradoc.them.org> <20080414150919.GB32227@caradoc.them.org> X-Yow: Mary Tyler Moore's SEVENTH HUSBAND is wearing my DACRON TANK TOP in a cheap hotel in HONOLULU! Date: Wed, 24 Sep 2008 12:46:00 -0000 In-Reply-To: <20080414150919.GB32227@caradoc.them.org> (Daniel Jacobowitz's message of "Mon, 14 Apr 2008 11:09:19 -0400") Message-ID: User-Agent: Gnus/5.110009 (No Gnus v0.9) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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-09/txt/msg00487.txt.bz2 Daniel Jacobowitz writes: > +# Start the program running and then wait for a bit, to be sure > +# that it can be attached to. > + > +set testpid [eval exec $binfile &] > + > +# No race > +sleep 2 > + > +# Do not: set testpid2 [expr $testpid + 1] > +# as it will not exist on Red Hat 2.6.9-34.0.2.ELsmp > +set testpid2 [expr $testpid + 2] > + > +set status2 /proc/${testpid}/task/${testpid2}/status > +if {[expr ! [file exists $status2]]} { > + # kernel-2.4 > + set status2 /proc/${testpid2}/status > +} There is no reason that this is required to work. Even if pids are allocated in increasing order there can be arbitrary other processes created between the start of the process and the creation of its threads. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."