|
@@ -1050,17 +1050,26 @@ int kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp)
|
|
|
|
|
|
int kill_pid_info(int sig, struct siginfo *info, struct pid *pid)
|
|
|
{
|
|
|
- int error;
|
|
|
+ int error = -ESRCH;
|
|
|
struct task_struct *p;
|
|
|
|
|
|
rcu_read_lock();
|
|
|
if (unlikely(sig_needs_tasklist(sig)))
|
|
|
read_lock(&tasklist_lock);
|
|
|
|
|
|
+retry:
|
|
|
p = pid_task(pid, PIDTYPE_PID);
|
|
|
- error = -ESRCH;
|
|
|
- if (p)
|
|
|
+ if (p) {
|
|
|
error = group_send_sig_info(sig, info, p);
|
|
|
+ if (unlikely(error == -ESRCH))
|
|
|
+ /*
|
|
|
+ * The task was unhashed in between, try again.
|
|
|
+ * If it is dead, pid_task() will return NULL,
|
|
|
+ * if we race with de_thread() it will find the
|
|
|
+ * new leader.
|
|
|
+ */
|
|
|
+ goto retry;
|
|
|
+ }
|
|
|
|
|
|
if (unlikely(sig_needs_tasklist(sig)))
|
|
|
read_unlock(&tasklist_lock);
|