--- kdbmain.c.orig	Sat Mar 29 10:16:06 2003
+++ kdbmain.c	Fri Apr  4 12:20:45 2003
@@ -2947,6 +2947,108 @@
 	return 0;
 }
 
+extern int kdb_wake_up_process(struct task_struct * p);
+
+/*
+ * kdb_kill
+ *
+ *	This function implements the 'kill' commands.
+ *
+ * Inputs:
+ *	argc	argument count
+ *	argv	argument vector
+ *	envp	environment vector
+ *	regs	registers at time kdb was entered.
+ * Outputs:
+ *	None.
+ * Returns:
+ *	zero for success, a kdb diagnostic if error
+ * Locking:
+ *	none.
+ * Remarks:
+ */
+int
+kdb_kill(int argc, const char **argv, const char **envp, struct pt_regs *regs)
+{
+	long sig, pid;
+	char *endp;
+	struct task_struct *p, *tg;
+	int find;
+	struct siginfo info;
+
+	if (argc!=2) {
+		kdb_printf("Invalid parameter number.\n");
+		return 0;
+	}
+
+	sig = simple_strtol(argv[1], &endp, 0);
+	if (*endp)
+		return KDB_BADINT;
+	if (sig >= 0 ) {
+		kdb_printf("Invalid signal parameter.<-signal>\n");
+		return 0;
+	}
+	sig=-sig;
+
+	pid = simple_strtol(argv[2], &endp, 0);
+	if (*endp)
+		return KDB_BADINT;
+	if (pid <=0 ) {
+		kdb_printf("Process ID must be large than 0.\n");
+		return 0;
+	}
+
+	/* Find the process. */
+	find = 0;
+	for_each_task(p) {
+		if(p->pid == pid) {
+			find = 1;
+			break;
+		}
+	}
+	if (find) {
+		/* In case the process is not a thread group leader, find the leader. */
+		if ( p->tgid != p->pid) {
+			for_each_task(tg) {
+				if(tg->pid == p->tgid) {
+					p = tg;
+					break;
+				}
+			}
+		}
+		if(spin_trylock(&p->sigmask_lock)) {
+			spin_unlock(&p->sigmask_lock);
+			if(spin_trylock(&runqueue_lock)) {
+				spin_unlock(&runqueue_lock);
+				info.si_signo = sig;
+				info.si_errno = 0;
+				info.si_code = SI_USER;
+				info.si_pid = current->pid;
+				info.si_uid = current->uid;
+				if(send_sig_info(sig, &info, p))
+					kdb_printf("Fail to deliver Signal %d to process %d.\n", sig, pid);
+				else
+					kdb_printf("Signal %d is sent to process %d.\n", sig, pid);
+			}
+			else {
+				kdb_printf("Can't do kill command now.\n\
+				The runqueue lock is held somewhere else in kernel.\n\
+				Try it later.");
+			}
+		}
+		else {
+			kdb_printf("Can't do kill command now.\n\
+			The sigmask lock is held somewhere else in kernel.\n\
+			Try it later.");
+		}
+	}
+	else {
+		kdb_printf("The specified process isn't found.\n");
+	}
+
+	return 0;
+}
+
 /*
  * kdb_register_repeat
  *
@@ -3162,6 +3264,7 @@
 #endif
 	kdb_register_repeat("dmesg", kdb_dmesg, "[lines]",	"Display syslog buffer", 0, KDB_REPEAT_NONE);
 	kdb_register_repeat("defcmd", kdb_defcmd, "name \"usage\" \"help\"", "Define a set of commands, down to endefcmd", 0, KDB_REPEAT_NONE);
+	kdb_register_repeat("kill", kdb_kill, "<-signal> <pid>", "Send a signal to a process", 0, KDB_REPEAT_NONE);
 
 	/* Any kdb commands that are not in the base code but are required
 	 * earlier than normal initcall processing.
