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/sched.h>
13 #include <asm/errno.h>
14 #include <asm/uaccess.h>
16 #include <linux/vs_base.h>
17 #include <linux/vs_context.h>
18 #include <linux/vserver/signal_cmd.h>
21 int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24 struct task_struct *p;
25 unsigned long priv = 0;
28 vxdprintk(VXD_CBIT(misc, 4),
29 "vx_info_kill(%p[#%d],%d,%d)*",
30 vxi, vxi->vx_id, pid, sig);
31 read_lock(&tasklist_lock);
39 if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
40 (pid && vxi->vx_initpid == p->pid))
43 err = group_send_sig_info(sig, (void*)priv, p);
51 if (vxi->vx_initpid) {
52 pid = vxi->vx_initpid;
57 p = find_task_by_real_pid(pid);
59 if (vx_task_xid(p) == vxi->vx_id)
60 retval = group_send_sig_info(sig,
65 read_unlock(&tasklist_lock);
66 vxdprintk(VXD_CBIT(misc, 4),
67 "vx_info_kill(%p[#%d],%d,%d) = %d",
68 vxi, vxi->vx_id, pid, sig, retval);
72 int vc_ctx_kill(uint32_t id, void __user *data)
75 struct vcmd_ctx_kill_v0 vc_data;
78 if (!vx_check(0, VX_ADMIN))
80 if (copy_from_user (&vc_data, data, sizeof(vc_data)))
83 vxi = lookup_vx_info(id);
87 retval = vx_info_kill(vxi, vc_data.pid, vc_data.sig);
93 static int __wait_exit(struct vx_info *vxi)
95 DECLARE_WAITQUEUE(wait, current);
98 add_wait_queue(&vxi->vx_wait, &wait);
99 set_current_state(TASK_INTERRUPTIBLE);
102 if (vx_info_state(vxi,
103 VXS_SHUTDOWN|VXS_HASHED|VXS_HELPER) == VXS_SHUTDOWN)
105 if (signal_pending(current)) {
113 set_current_state(TASK_RUNNING);
114 remove_wait_queue(&vxi->vx_wait, &wait);
120 int vc_wait_exit(uint32_t id, void __user *data)
123 struct vcmd_wait_exit_v0 vc_data;
126 vxi = lookup_vx_info(id);
130 ret = __wait_exit(vxi);
131 vc_data.reboot_cmd = vxi->reboot_cmd;
132 vc_data.exit_code = vxi->exit_code;
135 if (copy_to_user (data, &vc_data, sizeof(vc_data)))