This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]