Re: [patch] Fix Linux attach to signalled/stopped processes

Andreas Schwab
2008-09-24T12:46:32Z

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."