IB/mlx4: SET_PORT called by mlx4_ib_modify_port should be wrapped
[cascardo/linux.git] / kernel / exit.c
index 33cf8db..6ed6a1d 100644 (file)
@@ -1362,22 +1362,34 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
                return 0;
        }
 
-       /* slay zombie? */
-       if (p->exit_state == EXIT_ZOMBIE) {
+       if (likely(!ptrace) && unlikely(p->ptrace)) {
                /*
-                * A zombie ptracee is only visible to its ptracer.
-                * Notification and reaping will be cascaded to the real
-                * parent when the ptracer detaches.
+                * If it is traced by its real parent's group, just pretend
+                * the caller is ptrace_do_wait() and reap this child if it
+                * is zombie.
+                *
+                * This also hides group stop state from real parent; otherwise
+                * a single stop can be reported twice as group and ptrace stop.
+                * If a ptracer wants to distinguish these two events for its
+                * own children it should create a separate process which takes
+                * the role of real parent.
                 */
-               if (likely(!ptrace) && unlikely(p->ptrace)) {
-                       /* it will become visible, clear notask_error */
-                       wo->notask_error = 0;
-                       return 0;
-               }
+               if (!ptrace_reparented(p))
+                       ptrace = 1;
+       }
 
+       /* slay zombie? */
+       if (p->exit_state == EXIT_ZOMBIE) {
                /* we don't reap group leaders with subthreads */
-               if (!delay_group_leader(p))
-                       return wait_task_zombie(wo, p);
+               if (!delay_group_leader(p)) {
+                       /*
+                        * A zombie ptracee is only visible to its ptracer.
+                        * Notification and reaping will be cascaded to the
+                        * real parent when the ptracer detaches.
+                        */
+                       if (unlikely(ptrace) || likely(!p->ptrace))
+                               return wait_task_zombie(wo, p);
+               }
 
                /*
                 * Allow access to stopped/continued state via zombie by
@@ -1402,19 +1414,6 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
                if (likely(!ptrace) || (wo->wo_flags & (WCONTINUED | WEXITED)))
                        wo->notask_error = 0;
        } else {
-               /*
-                * If @p is ptraced by a task in its real parent's group,
-                * hide group stop/continued state when looking at @p as
-                * the real parent; otherwise, a single stop can be
-                * reported twice as group and ptrace stops.
-                *
-                * If a ptracer wants to distinguish the two events for its
-                * own children, it should create a separate process which
-                * takes the role of real parent.
-                */
-               if (likely(!ptrace) && p->ptrace && !ptrace_reparented(p))
-                       return 0;
-
                /*
                 * @p is alive and it's gonna stop, continue or exit, so
                 * there always is something to wait for.