#!/usr/bin/perl
#use Mooix::Thing;
run sub {
	my $this=shift;
	%_=@_;

	if ($this->candestroy) {
		# If this object is somewhere, it needs to be removed from 
		# that location.
		if ($this->location) {
			$this->msg('disappear', skip => $this)
				unless $_{quiet} || $this->hidden;
			$ret=$this->physics->move(object => $this, teleport => 1); # force away
		}
		
		# Call stackless helper method. It only lets this method run it.
		if ($] < 5.008) {
			# This signal handler is needed by older perls.
			$SIG{TERM}=sub {};
			return $this->dodestroy;
		}
		else {
			# In perl 5.8, for complex reasons to do with 
			# SIGTERM and perl's signal blocking and 
			# libmooproxy, I cannot run this as a normal
			# method. That's fine, since we just want to return
			# its value anyway.
			exec $this->fieldfile('dodestroy') || 
				$this->croak("failed to run dodestroy");
		}
	}
	else {
		return 1; # fail
	}
}
