2 * linux/kernel/vserver/signal.c
4 * Virtual Server: Signal Support
6 * Copyright (C) 2003-2004 Herbert Pƶtzl
8 * V0.01 broken out from vcontext V0.05
12 #include <linux/config.h>
13 #include <linux/sched.h>
15 #include <asm/errno.h>
16 #include <asm/uaccess.h>
18 #include <linux/vs_base.h>
19 #include <linux/vs_context.h>
20 #include <linux/vserver/signal.h>
23 int vc_ctx_kill(uint32_t id, void __user *data)
26 struct vcmd_ctx_kill_v0 vc_data;
28 struct task_struct *p;
31 if (!vx_check(0, VX_ADMIN))
33 if (copy_from_user (&vc_data, data, sizeof(vc_data)))
36 info.si_signo = vc_data.sig;
38 info.si_code = SI_USER;
39 info.si_pid = current->pid;
40 info.si_uid = current->uid;
42 vxi = locate_vx_info(id);
47 read_lock(&tasklist_lock);
48 switch (vc_data.pid) {
54 if (vx_task_xid(p) != id || p->pid <= 1 ||
55 (vc_data.pid && vxi->vx_initpid == p->pid) ||
56 !thread_group_leader(p))
59 err = send_sig_info(vc_data.sig, &info, p);
67 p = find_task_by_real_pid(vc_data.pid);
69 if (!thread_group_leader(p)) {
70 struct task_struct *tg;
72 tg = find_task_by_real_pid(p->tgid);
76 if ((id == -1) || (vx_task_xid(p) == id))
77 retval = send_sig_info(vc_data.sig, &info, p);
81 read_unlock(&tasklist_lock);
87 static int __wait_exit(struct vx_info *vxi)
89 DECLARE_WAITQUEUE(wait, current);
92 add_wait_queue(&vxi->vx_exit, &wait);
93 set_current_state(TASK_INTERRUPTIBLE);
96 if (vx_info_state(vxi, VXS_DEFUNCT))
98 if (signal_pending(current)) {
106 set_current_state(TASK_RUNNING);
107 remove_wait_queue(&vxi->vx_exit, &wait);
113 int vc_wait_exit(uint32_t id, void __user *data)
115 // struct vcmd_wait_exit_v0 vc_data;
119 vxi = locate_vx_info(id);
123 ret = __wait_exit(vxi);