Sysrq enhancement: process kill facility
Subsystems (4)
Hi,
Here's something that myself and others at Cobalt Networks have found useful. It extends sysrq to support a way to manually kill a process. In debugging situations, we have found times where the system gets wedged, and we'ld like to avoid a reboot. Show tasks provides the pid information.
You enter <alt>-<sysrq>-n ("nuke"), and then prompts for the pid. It supports backspace and control-U. On serial ports, it retains the same semantics:
a break activates this as a sysrq sequence, but if more than 5-seconds pass without any input, it drops out of processing input as a sysrq.
Feedback welcome, please cc: me directly.
Cheers,
~sparker
drivers/char/keyboard.c Thu Feb 7 17:59:18 2002 renamed from drivers/char/keyboard.c Tue Sep 18 13:39:51 2001 +1 -1
@@ -252,7 +252,7 @@ goto out; } else if (sysrq_pressed) { if (!up_flag) { - handle_sysrq(kbd_sysrq_xlate[keycode], kbd_pt_regs, kbd, tty); + (void) handle_sysrq(kbd_sysrq_xlate[keycode], kbd_pt_regs, kbd, tty); goto out; } }
Only in sysrq-generic-2.4.17/drivers/char: keyboard.c.orig
drivers/char/serial.c Thu Feb 7 17:59:18 2002 renamed from drivers/char/serial.c Fri Dec 21 09:41:54 2001 +6 -2
@@ -645,8 +645,12 @@ if (break_pressed && info->line == sercons.index) { if (ch != 0 && time_before(jiffies, break_pressed + HZ*5)) { - handle_sysrq(ch, regs, NULL, NULL); - break_pressed = 0; + if (!handle_sysrq(ch, regs, NULL, NULL)) { + break_pressed = 0; + } else { + /* reset time-out! more data needed */ + break_pressed = jiffies; + } goto ignore_char; } break_pressed = 0;
Only in sysrq-generic-2.4.17/drivers/char: serial.c.orig
drivers/char/serial_amba.c Thu Feb 7 17:59:18 2002 renamed from drivers/char/serial_amba.c Sun Sep 16 21:23:14 2001 +5 -2
@@ -356,8 +356,11 @@ #ifdef SUPPORT_SYSRQ if (info->sysrq) { if (ch && time_before(jiffies, info->sysrq)) { - handle_sysrq(ch, regs, NULL, NULL); - info->sysrq = 0; + if (!handle_sysrq(ch, regs, NULL, NULL)) { + info->sysrq = 0; + } else { + info->sysrq = jiffies; + } goto ignore_char; } info->sysrq = 0;
drivers/char/sysrq.c Thu Feb 7 17:59:18 2002 renamed from drivers/char/sysrq.c Fri Dec 21 09:41:54 2001 +111 -20
287 lines not on this page · raw message
drivers/s390/char/ctrlchar.c Thu Feb 7 17:59:18 2002 renamed from drivers/s390/char/ctrlchar.c Sun Sep 30 12:26:07 2001 +1 -1
@@ -26,7 +26,7 @@ static void ctrlchar_handle_sysrq(struct tty_struct *tty) { - handle_sysrq(ctrlchar_sysrq_key, NULL, NULL, tty); + (void) handle_sysrq(ctrlchar_sysrq_key, NULL, NULL, tty); } #endif
drivers/tc/zs.c Thu Feb 7 17:59:18 2002 renamed from drivers/tc/zs.c Mon Aug 27 08:56:31 2001 +6 -2
@@ -444,8 +444,12 @@ if (break_pressed && info->line == sercons.index) { if (ch != 0 && time_before(jiffies, break_pressed + HZ*5)) { - handle_sysrq(ch, regs, NULL, NULL); - break_pressed = 0; + if (!handle_sysrq(ch, regs, NULL, NULL)) { + break_pressed = 0; + } else { + /* reset time-out! more data needed */ + break_pressed = jiffies; + } goto ignore_char; } break_pressed = 0;
include/linux/sysrq.h Thu Feb 7 17:59:18 2002 renamed from include/linux/sysrq.h Wed Jan 30 16:47:01 2002 +1 -1
@@ -18,7 +18,7 @@ struct tty_struct; struct sysrq_key_op { - void (*handler)(int, struct pt_regs *, + int (*handler)(int, struct pt_regs *, struct kbd_struct *, struct tty_struct *); char *help_msg; char *action_msg;
@@ -29,9 +29,14 @@ /* Generic SysRq interface -- you may call it from any device driver,
supplying
* ASCII code of the key, pointer to registers and kbd/tty structs (if they
* are available -- else NULL's).
+ *
+ * Most sysrq's are single character commands, but to allow for multiple
+ * key-stroke input, handle_sysrq() returns true if the current command
+ * is collecting more input. This matters to serial-based consoles which
+ * base the interpretation of the character on the proximity of the break. */
-void handle_sysrq(int, struct pt_regs *,
+int handle_sysrq(int, struct pt_regs *,
struct kbd_struct *, struct tty_struct *);
@@ -40,7 +45,7 @@
* call sysrq handlers
*/
-void __handle_sysrq_nolock(int, struct pt_regs *, +int __handle_sysrq_nolock(int, struct pt_regs *,
struct kbd_struct *, struct tty_struct *);
Can this kill kill dead die go away forever D state processes?
David
Quoted 6 lines · S. Parker
Hi,
Here's something that myself and others at Cobalt Networks have found useful. It extends sysrq to support a way to manually kill a process. In debugging situations, we have found times where the system gets wedged, and we'ld like to avoid a reboot. Show tasks provides the pid information.
Hi!
Quoted 6 lines
Here's something that myself and others at Cobalt Networks have found useful.
It extends sysrq to support a way to manually kill a process. In debugging situations, we have found times where the system gets wedged, and we'ld like to avoid a reboot. Show tasks provides the pid information.
Quoted 7 lines
You enter <alt>-<sysrq>-n ("nuke"), and then prompts for the pid. It supports
backspace and control-U. On serial ports, it retains the same semantics:
a break activates this as a sysrq sequence, but if more than 5-seconds pass without any input, it drops out of processing input as a sysrq.Feedback welcome, please cc: me directly.
Looks good to me; (maybe you could reuse from 'kIll' as killing of all processes is hardly ever usefull).
Pavel
Signature · 2 lines
(about SSSCA) "I don't say this lightly. However, I really think that the U.S. no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
I certainly have no particular preference for what this is called. Is there support for dropping the existing kIll and me re-submitting these changes that way? (I've never imagined how kIll actually helped.)
Cheers,
~sparker
Quoted 9 lines · Pavel Machek
Hi!
Quoted 7 lines
You enter <alt>-<sysrq>-n ("nuke"), and then prompts for the pid. It supports
backspace and control-U. On serial ports, it retains the same semantics:
a break activates this as a sysrq sequence, but if more than 5-seconds pass without any input, it drops out of processing input as a sysrq.
Quoted 8 lines
Quoted 1 line
Feedback welcome, please cc: me directly.
Looks good to me; (maybe you could reuse from 'kIll' as killing of all processes is hardly ever usefull).
Pavel
--
(about SSSCA) "I don't say this lightly. However, I really think that theU.S. no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
Cheers,
~sparker