#!/usr/bin/perl
# This needs to be stackless.
#use Mooix::Thing;
use Mooix::CallStack;
#use Mooix::Root;
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 'startup' || $stack->index ne $init->index) {
                $this->croak("Permission denied; may only be run by init");
        }
	
	# This might be incorrect if the system crashed or something.
	$this->_heartbeat_running(0);
	
	# Run it and just exit, do not hang around waiting on the heartbeat
	# to stop.
	$ENV{MOOIX_NONSTANDARD}=$ENV{MOOIX_SHORT_CIRCUIT}=1;
	exec($this->fieldfile("heartbeat")) if $this->background;
}
