Re: ptrace.2: BUGS (missing WIFEXITED notification)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/12/2016 06:15 PM, Denys Vlasenko wrote:
On 08/12/2016 04:50 PM, Vegard Nossum wrote:
  stop will happen for it (if requested), but the subsequent WIFEXITED
  notification will not be delivered until all other threads exit.
+(As a corollary, if the other threads in the thread group are being
+traced, they will not exit until they have been either waited for
+and restarted or detached, thereby blocking the exit notification
+of the group leader to wait(2) and waitpid(2).)


Are you trying to prevent others falling into the same trap you fell into:
thinking that if you see PTRACE_EVENT_EXIT on a thread, it has exited?

Yes, or not exactly; more precisely, the trap we fell into was thinking
that if we see PTRACE_EVENT_EXIT, that means waitpid() will return
immediately. I know, the distinction is kind of subtle...

I think your wording is not good at that. How about this?


  stop will happen for it (if requested), but the subsequent WIFEXITED
  notification will not be delivered until all other threads exit.
+(Note that other threads, if they are traced and are in
+PTRACE_EVENT_EXIT ptrace-stop, they did not exit yet.
+If you assume otherwise and wait on a thread leader to exit now,
+this may hang.
+You need to restart or detach them for them to exit. Generally,
+only seeing WIFEXITED or WIFSIGNALED status from the thread is
+a definite sign that it exited).

Alright, another iteration on your version gives the following:

"""
Keep in mind that other threads in the thread group which are in a
PTRACE_EVENT_EXIT ptrace-stop have not actually exited yet. This means
that attempting to wait for the group leader with waitpid() will hang
indefinitely. In order prevent this, you must make sure that the other
threads exit properly by either restarting them or detaching from them.
In general, only WIFEXITED and WIFSIGNALED indicate that the child
has definitely exited.
"""


Vegard
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux