Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.4.19 /kernel/signal.c

Filename:/kernel/signal.c
Lines Added:71
Lines Deleted:4
Also changed in: (Previous) 2.4.19-rc5-ac1  2.4.19-rc5  2.4.19-rc4  2.4.19-rc3-ac5  2.4.19-rc3-ac4  2.4.19-rc3-ac3 
(Following) 2.4.19-ac1  2.4.19-ac2  2.4.19-ac3  2.4.19-ac4  2.4.20-pre1-ac1  2.4.20-pre1-ac2 

Location
[  2.4.19
  [  kernel
     o  signal.c

Patch

diff -urN linux-2.4.18/kernel/signal.c linux-2.4.19/kernel/signal.c
--- linux-2.4.18/kernel/signal.c   Wed Nov 21 16:26:27 2001
+++ linux-2.4.19/kernel/signal.c   Fri Aug  2 17:39:46 2002
@@ -142,6 +142,35 @@
    }
 }
 
+/*
+ * sig_exit - cause the current task to exit due to a signal.
+ */
+
+void
+sig_exit(int sig, int exit_code, struct siginfo *info)
+{
+   struct task_struct *t;
+
+   sigaddset(¤t->pending.signal, sig);
+   recalc_sigpending(current);
+   current->flags |= PF_SIGNALED;
+
+   /* Propagate the signal to all the tasks in
+    *  our thread group
+    */
+   if (info && (unsigned long)info != 1
+       && info->si_code != SI_TKILL) {
+      read_lock(&tasklist_lock);
+      for_each_thread(t) {
+         force_sig_info(sig, info, t);
+      }
+      read_unlock(&tasklist_lock);
+   }
+
+   do_exit(exit_code);
+   /* NOTREACHED */
+}
+
 /* Notify the system that a driver wants to block all signals for this
  * process, and wants to be notified if any signals at all were to be
  * sent/acted upon.  If the notifier routine returns non-zero, then the
@@ -519,7 +548,7 @@
    if (bad_signal(sig, info, t))
       goto out_nolock;
 
-   /* The null signal is a permissions and process existance probe.
+   /* The null signal is a permissions and process existence probe.
       No signal is actually delivered.  Same goes for zombies. */
    ret = 0;
    if (!sig || !t->sig)
@@ -592,7 +621,7 @@
       retval = -ESRCH;
       read_lock(&tasklist_lock);
       for_each_task(p) {
-         if (p->pgrp == pgrp) {
+         if (p->pgrp == pgrp && thread_group_leader(p)) {
             int err = send_sig_info(sig, info, p);
             if (retval)
                retval = err;
@@ -639,8 +668,15 @@
    read_lock(&tasklist_lock);
    p = find_task_by_pid(pid);
    error = -ESRCH;
-   if (p)
+   if (p) {
+      if (!thread_group_leader(p)) {
+                       struct task_struct *tg;
+                       tg = find_task_by_pid(p->tgid);
+                       if (tg)
+                               p = tg;
+                }
       error = send_sig_info(sig, info, p);
+   }
    read_unlock(&tasklist_lock);
    return error;
 }
@@ -663,7 +699,7 @@
 
       read_lock(&tasklist_lock);
       for_each_task(p) {
-         if (p->pid > 1 && p != current) {
+         if (p->pid > 1 && p != current && thread_group_leader(p)) {
             int err = send_sig_info(sig, info, p);
             ++count;
             if (err != -EPERM)
@@ -988,6 +1024,36 @@
    return kill_something_info(sig, &info, pid);
 }
 
+/*
+ *  Kill only one task, even if it's a CLONE_THREAD task.
+ */
+asmlinkage long
+sys_tkill(int pid, int sig)
+{
+       struct siginfo info;
+       int error;
+       struct task_struct *p;
+
+       /* This is only valid for single tasks */
+       if (pid <= 0)
+           return -EINVAL;
+
+       info.si_signo = sig;
+       info.si_errno = 0;
+       info.si_code = SI_TKILL;
+       info.si_pid = current->pid;
+       info.si_uid = current->uid;
+
+       read_lock(&tasklist_lock);
+       p = find_task_by_pid(pid);
+       error = -ESRCH;
+       if (p) {
+               error = send_sig_info(sig, &info, p);
+       }
+       read_unlock(&tasklist_lock);
+       return error;
+}
+
 asmlinkage long
 sys_rt_sigqueueinfo(int pid, int sig, siginfo_t *uinfo)
 {
@@ -1047,6 +1113,7 @@
           || (k->sa.sa_handler == SIG_DFL
          && (sig == SIGCONT ||
              sig == SIGCHLD ||
+             sig == SIGURG ||
              sig == SIGWINCH))) {
          spin_lock_irq(¤t->sigmask_lock);
          if (rm_sig_from_queue(sig, current))


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.