#!/usr/bin/perl
# This needs to be stackless so it can signal.
#use Mooix::Thing;
use Mooix::CallStack;
#use Mooix::Root;
use POSIX q{SIGINT};
run sub {
	my $this=shift;

        # Check to see that we were run by init, and there is nothing else
        # on the stack.
        my $init=$Mooix::Root->system->init;
        my $stack=Mooix::CallStack::get();
        # Advance on to the next stack frame -- since this method is
        # stackless, that is its caller.
        my $stack=$stack->nextsegment;
        if (! $stack || $stack->nextsegment ||
            $stack->basemethod ne 'shutdown' || $stack->index ne $init->index) {
                $this->croak("Permission denied; may only be run by init");
        }

	$SIG{INT}='IGNORE';
	$this->signal(with => SIGINT);
	# Make good and sure that it's gone.
	$this->_heartbeat_running(0);
}
