Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 11826
b: refs/heads/master
c: 6dd69f1
h: refs/heads/master
v: v3
  • Loading branch information
Vadim Lobanov authored and Linus Torvalds committed Oct 31, 2005
1 parent 2879c26 commit 81431d5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 47 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 19a4fcb531659f2f7d18b5d04cee039176e9540d
refs/heads/master: 6dd69f1061bfdeca230509b173438e0731bff767
71 changes: 25 additions & 46 deletions trunk/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2283,26 +2283,13 @@ sys_kill(int pid, int sig)
return kill_something_info(sig, &info, pid);
}

/**
* sys_tgkill - send signal to one specific thread
* @tgid: the thread group ID of the thread
* @pid: the PID of the thread
* @sig: signal to be sent
*
* This syscall also checks the tgid and returns -ESRCH even if the PID
* exists but it's not belonging to the target process anymore. This
* method solves the problem of threads exiting and PIDs getting reused.
*/
asmlinkage long sys_tgkill(int tgid, int pid, int sig)
static int do_tkill(int tgid, int pid, int sig)
{
struct siginfo info;
int error;
struct siginfo info;
struct task_struct *p;

/* This is only valid for single tasks */
if (pid <= 0 || tgid <= 0)
return -EINVAL;

error = -ESRCH;
info.si_signo = sig;
info.si_errno = 0;
info.si_code = SI_TKILL;
Expand All @@ -2311,8 +2298,7 @@ asmlinkage long sys_tgkill(int tgid, int pid, int sig)

read_lock(&tasklist_lock);
p = find_task_by_pid(pid);
error = -ESRCH;
if (p && (p->tgid == tgid)) {
if (p && (tgid <= 0 || p->tgid == tgid)) {
error = check_kill_permission(sig, &info, p);
/*
* The null signal is a permissions and process existence
Expand All @@ -2326,47 +2312,40 @@ asmlinkage long sys_tgkill(int tgid, int pid, int sig)
}
}
read_unlock(&tasklist_lock);

return error;
}

/**
* sys_tgkill - send signal to one specific thread
* @tgid: the thread group ID of the thread
* @pid: the PID of the thread
* @sig: signal to be sent
*
* This syscall also checks the tgid and returns -ESRCH even if the PID
* exists but it's not belonging to the target process anymore. This
* method solves the problem of threads exiting and PIDs getting reused.
*/
asmlinkage long sys_tgkill(int tgid, int pid, int sig)
{
/* This is only valid for single tasks */
if (pid <= 0 || tgid <= 0)
return -EINVAL;

return do_tkill(tgid, pid, sig);
}

/*
* Send a signal to 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->tgid;
info.si_uid = current->uid;

read_lock(&tasklist_lock);
p = find_task_by_pid(pid);
error = -ESRCH;
if (p) {
error = check_kill_permission(sig, &info, p);
/*
* The null signal is a permissions and process existence
* probe. No signal is actually delivered.
*/
if (!error && sig && p->sighand) {
spin_lock_irq(&p->sighand->siglock);
handle_stop_signal(sig, p);
error = specific_send_sig_info(sig, &info, p);
spin_unlock_irq(&p->sighand->siglock);
}
}
read_unlock(&tasklist_lock);
return error;
return do_tkill(0, pid, sig);
}

asmlinkage long
Expand Down

0 comments on commit 81431d5

Please sign in to comment.