Group: linux.gentoo.user
From: Steven Lembark
Date: Monday, April 07, 2008 12:40 PM
Subject: Re: [gentoo-user] Re: Emergency shutdown, how to?

Iain Buchanan wrote:
> On Sat, 2008-04-05 at 12:42 -0400, Steven Lembark wrote:
>>> I tried ALT + SysRq + EISUB today on my MythTV backend server which
>>> has been crashing lately. Unfortunately it's crashing so badly that
>>> even at the server's keyboard this didn't work.
>>>
>>> I guess my weekend fate of building a new server is sealed...
>> Have fun.
>>
>> Check out motherboards with watchdog capability
>> and enable it in the kernel.
>
> watchdogs are nice, and linux makes them ultra-easy to program, but of
> course if your watchdog task dies, then the machine effectively hits the
> reset button for you - no nice shutdown whatsoever! (Which is what you
> want in a hard lock-up, but not if your programming skills are the cause
> of the problem :)

- Have the system turn off the watchdog if the file is
closed.

- After that just open it and poke a bit out now and
then.

- Make a point of closing the file on exit.

#!/usr/bin/perl

use strict;

open my $fh, '<', '/path/to/watchdog/file'
or die "Failed opening watchdog file: $!";

# watchdog is now watching...

select $fh;

for(;;)
{
print "\n";

sleep 1; # watchdog timeout / 2
}

my $graceful_exit
= sub
{
close $fh;

exit 0
};

for sig in ( qw( TERM QUIT INT __DIE__ ) )
{
$SIG{ $sig } = $graceful_exit;
}

for sig in ( qw( HUP ) )
{
$SIG{ $SIG } = 'IGNORE';
}

__END__

--
Steven Lembark 85-09 90th St.
Workhorse Computing Woodhaven, NY, 11421
lembark@wrkhors.com +1 888 359 3508
--
gentoo-user@lists.gentoo.org mailing list

Safety Articles | Usenet Groups | Usenet News | Bluegrass