Gentoo Archives: gentoo-user

From: Steven Lembark <lembark@×××××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: Emergency shutdown, how to?
Date: Mon, 07 Apr 2008 17:36:35
Message-Id: 47FA59DA.9090404@wrkhors.com
In Reply to: Re: [gentoo-user] Re: Emergency shutdown, how to? by Iain Buchanan
1 Iain Buchanan wrote:
2 > On Sat, 2008-04-05 at 12:42 -0400, Steven Lembark wrote:
3 >>> I tried ALT + SysRq + EISUB today on my MythTV backend server which
4 >>> has been crashing lately. Unfortunately it's crashing so badly that
5 >>> even at the server's keyboard this didn't work.
6 >>>
7 >>> I guess my weekend fate of building a new server is sealed...
8 >> Have fun.
9 >>
10 >> Check out motherboards with watchdog capability
11 >> and enable it in the kernel.
12 >
13 > watchdogs are nice, and linux makes them ultra-easy to program, but of
14 > course if your watchdog task dies, then the machine effectively hits the
15 > reset button for you - no nice shutdown whatsoever! (Which is what you
16 > want in a hard lock-up, but not if your programming skills are the cause
17 > of the problem :)
18
19 - Have the system turn off the watchdog if the file is
20 closed.
21
22 - After that just open it and poke a bit out now and
23 then.
24
25 - Make a point of closing the file on exit.
26
27 #!/usr/bin/perl
28
29 use strict;
30
31 open my $fh, '<', '/path/to/watchdog/file'
32 or die "Failed opening watchdog file: $!";
33
34 # watchdog is now watching...
35
36 select $fh;
37
38 for(;;)
39 {
40 print "\n";
41
42 sleep 1; # watchdog timeout / 2
43 }
44
45 my $graceful_exit
46 = sub
47 {
48 close $fh;
49
50 exit 0
51 };
52
53 for sig in ( qw( TERM QUIT INT __DIE__ ) )
54 {
55 $SIG{ $sig } = $graceful_exit;
56 }
57
58 for sig in ( qw( HUP ) )
59 {
60 $SIG{ $SIG } = 'IGNORE';
61 }
62
63 __END__
64
65 --
66 Steven Lembark 85-09 90th St.
67 Workhorse Computing Woodhaven, NY, 11421
68 lembark@×××××××.com +1 888 359 3508
69 --
70 gentoo-user@l.g.o mailing list

Replies

Subject Author
Re: [gentoo-user] Re: Emergency shutdown, how to? Iain Buchanan <iaindb@××××××××××××.au>