This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Workaround for glibc/BZ5983: following a child fork shows stale parent threads in the child.
Doug Evans <dje@google.com> writes:
> On Mon, May 18, 2009 at 10:13 AM, Pedro Alves <pedro@codesourcery.com> wrote:
>> [...]
>> + Â Â Âwhile (fgets (buf, sizeof (buf), status_file))
>> + Â Â Â {
>> + Â Â Â Â if (strncmp (buf, "Tgid:", 5) == 0)
>> + Â Â Â Â Â {
>> + Â Â Â Â Â Â tgid = strtoul (buf + strlen ("Tgid:"), NULL, 10);
>> + Â Â Â Â Â Â break;
>> + Â Â Â Â Â }
>> + Â Â Â }
>
> This works, but only because of an assumption of the strlen including
> the trailing NUL in "Tgid:" consuming the TAB between "Tgid:" and the
> number.
strlen does not include the trailing NUL, sizeof does.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."