diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-04-04 17:01:01 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2009-04-30 13:24:23 -0400 |
commit | 30b4ae8a4498543863501f707879b7220b649602 (patch) | |
tree | c8207d2f7221b5b89b1e7cb6b896135f0f061f69 /kernel/signal.c | |
parent | 091438dd5668396328a3419abcbc6591159eb8d1 (diff) |
signals: split do_tkill
Split out the code from do_tkill to make it reusable by the follow up
patch which implements sys_rt_tgsigqueueinfo
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Diffstat (limited to 'kernel/signal.c')
-rw-r--r-- | kernel/signal.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/kernel/signal.c b/kernel/signal.c index d8034737db4c..56d27acad87e 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -2278,24 +2278,17 @@ SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) | |||
2278 | return kill_something_info(sig, &info, pid); | 2278 | return kill_something_info(sig, &info, pid); |
2279 | } | 2279 | } |
2280 | 2280 | ||
2281 | static int do_tkill(pid_t tgid, pid_t pid, int sig) | 2281 | static int |
2282 | do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info) | ||
2282 | { | 2283 | { |
2283 | int error; | ||
2284 | struct siginfo info; | ||
2285 | struct task_struct *p; | 2284 | struct task_struct *p; |
2286 | unsigned long flags; | 2285 | unsigned long flags; |
2287 | 2286 | int error = -ESRCH; | |
2288 | error = -ESRCH; | ||
2289 | info.si_signo = sig; | ||
2290 | info.si_errno = 0; | ||
2291 | info.si_code = SI_TKILL; | ||
2292 | info.si_pid = task_tgid_vnr(current); | ||
2293 | info.si_uid = current_uid(); | ||
2294 | 2287 | ||
2295 | rcu_read_lock(); | 2288 | rcu_read_lock(); |
2296 | p = find_task_by_vpid(pid); | 2289 | p = find_task_by_vpid(pid); |
2297 | if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) { | 2290 | if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) { |
2298 | error = check_kill_permission(sig, &info, p); | 2291 | error = check_kill_permission(sig, info, p); |
2299 | /* | 2292 | /* |
2300 | * The null signal is a permissions and process existence | 2293 | * The null signal is a permissions and process existence |
2301 | * probe. No signal is actually delivered. | 2294 | * probe. No signal is actually delivered. |
@@ -2305,7 +2298,7 @@ static int do_tkill(pid_t tgid, pid_t pid, int sig) | |||
2305 | * signal is private anyway. | 2298 | * signal is private anyway. |
2306 | */ | 2299 | */ |
2307 | if (!error && sig && lock_task_sighand(p, &flags)) { | 2300 | if (!error && sig && lock_task_sighand(p, &flags)) { |
2308 | error = specific_send_sig_info(sig, &info, p); | 2301 | error = specific_send_sig_info(sig, info, p); |
2309 | unlock_task_sighand(p, &flags); | 2302 | unlock_task_sighand(p, &flags); |
2310 | } | 2303 | } |
2311 | } | 2304 | } |
@@ -2314,6 +2307,19 @@ static int do_tkill(pid_t tgid, pid_t pid, int sig) | |||
2314 | return error; | 2307 | return error; |
2315 | } | 2308 | } |
2316 | 2309 | ||
2310 | static int do_tkill(pid_t tgid, pid_t pid, int sig) | ||
2311 | { | ||
2312 | struct siginfo info; | ||
2313 | |||
2314 | info.si_signo = sig; | ||
2315 | info.si_errno = 0; | ||
2316 | info.si_code = SI_TKILL; | ||
2317 | info.si_pid = task_tgid_vnr(current); | ||
2318 | info.si_uid = current_uid(); | ||
2319 | |||
2320 | return do_send_specific(tgid, pid, sig, &info); | ||
2321 | } | ||
2322 | |||
2317 | /** | 2323 | /** |
2318 | * sys_tgkill - send signal to one specific thread | 2324 | * sys_tgkill - send signal to one specific thread |
2319 | * @tgid: the thread group ID of the thread | 2325 | * @tgid: the thread group ID of the thread |