From: Nick 'S. M. <sh...@zo...> - 2002-02-21 07:02:36
|
G'day Jeff & list, I've been playing with virtual networks of UML hosts, and one thing that's been annoying me is that it's difficult to shut the network down cleanly. Here's a patch which catches a SIGHUP to the tracing thread and calls the kernel ctrl_alt_del() procedure. If I'm doing this a totally bone-headed way, I'm sure you'll let me know ... hey, I said it was trivial! -----sharks -----8<-----cut here-----8<----- Based on 2.4.16-2 diff -c trap_kern.orig.c trap_kern.c *** trap_kern.orig.c Thu Feb 21 17:40:46 2002 --- trap_kern.c Thu Feb 21 17:42:24 2002 *************** *** 274,279 **** --- 274,286 ---- init_proxy(debugger_pid, 0, 0); } + void signal_hup(int sig) + { + printk(KERN_ERR "Tracing thread caught SIGHUP: simulating ctrl-alt-del\n"); + /* do I have to do anything clever here? */ + ctrl_alt_del(); + } + int init_ptrace_proxy(int idle_pid, int startup, int stop) { int pid, status; diff -c trap_user.orig.c trap_user.c *** trap_user.orig.c Thu Feb 21 17:40:34 2002 --- trap_user.c Thu Feb 21 17:46:30 2002 *************** *** 114,119 **** --- 114,120 ---- extern int io_nsignals, io_count, intr_count; extern void signal_usr1(int sig); + extern void signal_hup(int sig); int tracing_pid = -1; *************** *** 129,134 **** --- 130,136 ---- calc_sigframe_size(); signal(SIGSEGV, signal_segv); signal(SIGUSR1, signal_usr1); + signal(SIGHUP, signal_hup); signal(SIGPIPE, SIG_IGN); tracing_pid = getpid(); printk("tracing thread pid = %d\n", tracing_pid); -----8<-----cut here-----8<----- -- Nick 'Sharkey' Moore <Nic...@en...> Research Fellow, CTIE Tel: +61 3 9905 3707 Monash University, Australia Fax: +61 3 9905 5358 |
From: Jeff D. <jd...@ka...> - 2002-02-21 14:57:00
|
sh...@zo... said: > If I'm doing this a totally bone-headed way, I'm sure you'll let me > know ... hey, I said it was trivial! The tracing thread shouldn't call into the kernel like that. Actual kernel threads are the only things that should be running kernel code. What's the matter with the mconsole 'cad' command (aside from the fact that I think it's not documented anywhere :-)? Jeff |
From: Nick 'S. M. <sh...@zo...> - 2002-02-21 22:35:57
|
On Thu, Feb 21, 2002 at 09:58:37AM -0500, Jeff Dike wrote: > sh...@zo... said: > > If I'm doing this a totally bone-headed way, I'm sure you'll let me > > know ... hey, I said it was trivial! > > The tracing thread shouldn't call into the kernel like that. Actual kernel > threads are the only things that should be running kernel code. Oh, fair enough. I was hoping the eventual behavior (finding pid 1 and SIGINTing it) would sort itself out. I guess a better way would be for the tracing thread to catch SIGHUP, and to SIGHUP a kernel thread, which would then SIGINT the init thread. Maybe? > What's the matter with the mconsole 'cad' command (aside from the fact that > I think it's not documented anywhere :-)? Ah, well, mainly that I didn't know it existed. I'd still like to be able to do it with a signal, just so I can script horrible things like: ps auxww | grep 'tracing\ thread' | awk '{print $2;}' | xargs kill -HUP Hopefully something useful should come out of all this mucking around: I'm setting up IPv6 virtual networks & trying to do simulation and conformance testing using UML. There's probably a paper in it :-) -----sharks |
From: Matt Z. <md...@de...> - 2002-02-21 22:47:06
|
On Fri, Feb 22, 2002 at 09:35:43AM +1100, Nick 'Sharkey' Moore wrote: > Ah, well, mainly that I didn't know it existed. I'd still like to be able > to do it with a signal, just so I can script horrible things like: > > ps auxww | grep 'tracing\ thread' | awk '{print $2;}' | xargs kill -HUP > > Hopefully something useful should come out of all this mucking around: I'm > setting up IPv6 virtual networks & trying to do simulation and conformance > testing using UML. There's probably a paper in it :-) It should be even easier to script with mconsole, something like: mconsole $(find the UML socket in ~/.uml) cad probably the socket with the most recent mtime or some such would do. -- - mdz |
From: Jeff D. <jd...@ka...> - 2002-02-21 23:02:44
|
sh...@zo... said: > I'd still like to be able to do it with a signal, just so I can script > horrible things like: What's wrong with uml_mconsole umid cad ? Jeff |
From: Nick 'S. M. <sh...@zo...> - 2002-02-22 03:54:02
|
On Thu, Feb 21, 2002 at 01:04:49PM -0500, Jeff Dike wrote: > > What's wrong with > uml_mconsole umid cad Oh, just the usual: I hadn't realised I could do that :-) [Re: the -users thread on halting] Anyway, if you'd rather go to runlevel 0 than runlevel 6, just change /etc/inittab: # What to do when CTRL-ALT-DEL is pressed. ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -h now -----sharks |