This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Fix Linux attach to signalled/stopped processes
- From: Andreas Schwab <schwab at suse dot de>
- To: Roland McGrath <roland at redhat dot com>
- Cc: Jan Kratochvil <jan dot kratochvil at redhat dot com>, Doug Evans <dje at google dot com>, GDB Patches <gdb-patches at sourceware dot org>, mark dot kettenis at xs4all dot nl
- Date: Wed, 24 Sep 2008 14:45:46 +0200
- Subject: Re: [patch] Fix Linux attach to signalled/stopped processes
- References: <e394668d0803311218x35c802c1g7dba5f3b48b38bc8@mail.gmail.com> <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>
Daniel Jacobowitz <drow@false.org> 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."