summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-09-29 09:36:05 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-09-29 09:36:05 +0000
commita9d8f8818f51b039333984dd38e42a3078efc5b0 (patch)
tree6bb7e1b8aecf5abae7237a84f723a08eabbdb5c3 /sys/kern
parenteb58ac5b3ac3fb526c35c7455e27e6463949add8 (diff)
New ddb(4) command: kill.
Send an uncatchable SIGABRT to the process specified by the pid argument. Useful in case of CPU exhaustion to kill the DoSing process and generate a core for later inspection. ok phessler@, visa@, kettenis@, miod@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_proc.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 2436de90016..37ad3232b75 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_proc.c,v 1.76 2017/02/04 07:42:52 guenther Exp $ */
+/* $OpenBSD: kern_proc.c,v 1.77 2017/09/29 09:36:04 mpi Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
@@ -440,6 +440,28 @@ proc_printit(struct proc *p, const char *modif,
#include <ddb/db_output.h>
void
+db_kill_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif)
+{
+ struct process *pr;
+ struct sigaction sa;
+ struct proc *p;
+
+ pr = prfind(addr);
+ if (pr == NULL) {
+ db_printf("%ld: No such process", addr);
+ return;
+ }
+
+ p = TAILQ_FIRST(&pr->ps_threads);
+
+ /* Send uncatchable SIGABRT for coredump */
+ memset(&sa, 0, sizeof sa);
+ sa.sa_handler = SIG_DFL;
+ setsigvec(p, SIGABRT, &sa);
+ psignal(p, SIGABRT);
+}
+
+void
db_show_all_procs(db_expr_t addr, int haddr, db_expr_t count, char *modif)
{
char *mode;