[RFC patch 2/3] signals: implement sys_rt_tgsigqueueinfo

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: LKML <linux-kernel@...>
Cc: Ingo Molnar <mingo@...>, Ulrich Drepper <drepper@...>, Roland McGrath <roland@...>, Oleg Nesterov <oleg@...>, Michael Kerrisk <mtk.manpages@...>
Date: Tuesday, September 30, 2008 - 3:49 pm

sys_kill has the per thread counterpart sys_tgkill. sigqueueinfo is
missing a thread directed counterpart. Such an interface is important
for migrating applications from other OSes which have the per thread
delivery implemented.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/signal.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Index: linux-2.6-tip/kernel/signal.c
===================================================================
--- linux-2.6-tip.orig/kernel/signal.c
+++ linux-2.6-tip/kernel/signal.c
@@ -2307,6 +2307,27 @@ sys_rt_sigqueueinfo(pid_t pid, int sig, 
 	return kill_proc_info(sig, &info, pid);
 }
 
+asmlinkage long
+sys_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t __user *uinfo)
+{
+	siginfo_t info;
+
+	/* This is only valid for single tasks */
+	if (pid <= 0 || tgid <= 0)
+		return -EINVAL;
+
+	if (copy_from_user(&info, uinfo, sizeof(siginfo_t)))
+		return -EFAULT;
+
+	/* Not even root can pretend to send signals from the kernel.
+	   Nor can they impersonate a kill(), which adds source info.  */
+	if (info.si_code >= 0)
+		return -EPERM;
+	info.si_signo = sig;
+
+	return do_send_specific(tgid, pid, sig, &info);
+}
+
 int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
 {
 	struct task_struct *t = current;


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC patch 2/3] signals: implement sys_rt_tgsigqueueinfo, Thomas Gleixner, (Tue Sep 30, 3:49 pm)