> ptrace(PTRACE_ATTACH, 19779, 0, 0)      = 0
> --- SIGCHLD (Child exited) @ a000000000010621 (2aff00004d43) ---
> wait4(19779, 0x60000fffffb7b4b4, WUNTRACED, NULL) = -1 ECHILD (No child 
> processes)

Oh, you need __WALL if you are tracing non-main threads too.  (And
technically you don't need WUNTRACED, as ptrace'd threads report in
WIFSTOPPED states regardless.  But WUNTRACED does not hurt.)

> Well, I am using regular kill(). 

That's your problem.  I assumed when you said "sent to the tid" that you
understood that kill never does this.  

> I did not know about tkill(). This one seems to accept regular pid as
> well, right?

I don't think I understand the question.  So I'll give you an answer that
probably only makes sense to me.  In Linux, what's usually called "PID" is
a per-thread identifier (TID), which happens to match exactly the
per-process identifier called in Linuxspeak "TGID" (thread group ID), which
is what in the rest of the world is called a PID.  When using ptrace and
wait, you are always in fact dealing with individual thread IDs.  Normal
wait in the absence of ptrace refers to PIDs (whole process whose initial
thread's TID==PID).  For wait on ptrace'd threads, the initial thread's TID
(the PID) behaves like other threads when that thread is stopping, but
behaves as the process-wide identifier (as in non-ptrace wait) when that
thread dies.  kill sends a signal to a process by PID, as defined by POSIX.
tgkill/tkill sends a signal to a particular thread by TID.  tkill is
deprecated because it is racy with PID reuse in some cases.  tgkill takes
the TID of the target thread and also the TGID (PID) of the target thread
group (process) to verify that the TID was not reused.  When you have
ptrace attached to a thread, its TID can only be reused after you've seen
it die with wait* or have PTRACE_DETACH'd it, or if any thread in its
process does an exec.


Thanks,
Roland
_______________________________________________
perfmon mailing list
[email protected]
http://www.hpl.hp.com/hosted/linux/mail-archives/perfmon/

Reply via email to