[ cc severely trimmed ]
Dag-Erling Smorgrav <[EMAIL PROTECTED]> writes:
> I would *love* to have a DDB equivalent to 'kill -9', so I could drop
> to the DDB prompt, check ps, kill a process or two, and drop back out
> of DDB. It would have saved me a reboot and a longish fsck in this
> case.
Mmm.. I implemented something like this a few days ago for similar
reasons. Essentially it's a ddb interface to psignal(). I haven't
tried using it to kill something like your program, but I have no
reason to think it wouldn't work.
Short patch attached. Sample use:
db> kill 9 0t500
where '9' is the signal number and '500' is the process id.
Dima Dorfman
[EMAIL PROTECTED]
Index: db_command.c
===================================================================
RCS file: /st/src/FreeBSD/src/sys/ddb/db_command.c,v
retrieving revision 1.34
diff -u -r1.34 db_command.c
--- db_command.c 1999/08/28 00:41:06 1.34
+++ db_command.c 2001/05/08 23:37:59
@@ -36,7 +36,11 @@
*/
#include <sys/param.h>
#include <sys/linker_set.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
#include <sys/reboot.h>
+#include <sys/signalvar.h>
#include <sys/systm.h>
#include <sys/cons.h>
@@ -61,6 +65,7 @@
static db_cmdfcn_t db_fncall;
static db_cmdfcn_t db_gdb;
+static db_cmdfcn_t db_kill;
/* XXX this is actually forward-static. */
extern struct command db_show_cmds[];
@@ -405,6 +410,7 @@
{ "show", 0, 0, db_show_cmds },
{ "ps", db_ps, 0, 0 },
{ "gdb", db_gdb, 0, 0 },
+ { "kill", db_kill, CS_OWN, 0 },
{ (char *)0, }
};
@@ -558,4 +564,41 @@
db_printf("Next trap will enter %s\n",
boothowto & RB_GDB ? "GDB remote protocol mode"
: "DDB debugger");
+}
+
+static void
+db_kill(dummy1, dummy2, dummy3, dummy4)
+ db_expr_t dummy1;
+ boolean_t dummy2;
+ db_expr_t dummy3;
+ char * dummy4;
+{
+ struct proc *p;
+ db_expr_t sig, pid;
+
+ if (!db_expression(&sig)) {
+ db_printf("Missing signal number\n");
+ db_flush_lex();
+ return;
+ }
+ if (!db_expression(&pid)) {
+ db_printf("Missing process id\n");
+ db_flush_lex();
+ return;
+ }
+ db_skip_to_eol();
+ if (sig < 0 || sig > _SIG_MAXSIG) {
+ db_printf("Signal number out of range\n");
+ db_flush_lex();
+ return;
+ }
+
+ p = pfind(pid);
+ if (p == NULL) {
+ db_printf("Can't find process with pid %d\n", pid);
+ db_flush_lex();
+ return;
+ }
+ psignal(p, sig);
+ PROC_UNLOCK(p);
}
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message