[patch] Fix Linux attach to signalled/stopped processes

Roland McGrath roland@redhat.com
Sat Apr 12 07:58:00 GMT 2008


> There is a race if:
> * inferior was not stopped (a regular running process)

Ah, right.  You can also do:

	PTRACE_ATTACH		-> pending SIGSTOP
	... if running		-> stopped, no pending SIGSTOP
	... if stopped		-> still stopped, pending SIGSTOP
	tkill (SIGSTOP, tid)	-> pending SIGSTOP

	PTRACE_CONT, tid, 0	-> if not stopped the first time yet, ESRCH
				-> if stopped, wakes up, dequeues SIGSTOP
	wait			-> always see it stop

You just don't know whether you'll see one more spurious SIGSTOP or not.
(Once you've waited, you can synchronously check /proc, but that doesn't
tell you whether it was your spurious one or just an outside one sent
right now.)


Thanks,
Roland



More information about the Gdb-patches mailing list