2 * linux/kernel/vserver/signal.c
4 * Virtual Server: Signal Support
6 * Copyright (C) 2003-2005 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_context.h>
19 #include <linux/vserver/signal_cmd.h>
22 int vc_ctx_kill(uint32_t id, void __user *data)
25 struct vcmd_ctx_kill_v0 vc_data;
26 struct task_struct *p;
28 unsigned long priv = 0;
30 if (!vx_check(0, VX_ADMIN))
32 if (copy_from_user (&vc_data, data, sizeof(vc_data)))
35 vxi = locate_vx_info(id);
40 read_lock(&tasklist_lock);
41 switch (vc_data.pid) {
48 if (vx_task_xid(p) != id || p->pid <= 1 ||
49 (vc_data.pid && vxi->vx_initpid == p->pid))
52 err = group_send_sig_info(vc_data.sig, (void*)priv, p);
60 if (vxi->vx_initpid) {
61 vc_data.pid = vxi->vx_initpid;
66 p = find_task_by_real_pid(vc_data.pid);
68 if ((id == -1) || (vx_task_xid(p) == id))
69 retval = group_send_sig_info(vc_data.sig,
74 read_unlock(&tasklist_lock);
80 static int __wait_exit(struct vx_info *vxi)
82 DECLARE_WAITQUEUE(wait, current);
85 add_wait_queue(&vxi->vx_wait, &wait);
86 set_current_state(TASK_INTERRUPTIBLE);
89 if (vx_info_state(vxi, VXS_SHUTDOWN|VXS_HASHED) == VXS_SHUTDOWN)
91 if (signal_pending(current)) {
99 set_current_state(TASK_RUNNING);
100 remove_wait_queue(&vxi->vx_wait, &wait);
106 int vc_wait_exit(uint32_t id, void __user *data)
111 vxi = locate_vx_info(id);
115 ret = __wait_exit(vxi);