#!/usr/bin/perl
#use Mooix::Thing;
use POSIX;
run sub {
	my $this=shift;
	%_=@_;
	
	# Make sure that this command is not spoofed, just in case.
        if ($_{avatar} != $this) {
		fail "No!"; 
	}
	
	my $obj = $_{direct_object};
	my $session = $_{session};
	my $signal = POSIX::SIGTERM;
	$signal = $_{number} if exists $_{number};

	# The reason behind this paranoia is various hypothetical signal
	# attacks. Basically, since a signal can possible cause a program
	# to behave in ways that are not really intended, it's best to not
	# let builders play with it. This is overridden for programmers.
	if ($signal != POSIX::SIGTERM && $signal != POSIX::SIGKILL) {
		fail "As a builder, you're limited to signals ".POSIX::SIGTERM.
		     "and ".POSIX::SIGKILL.".";
	}
	
	my @args;
	if (exists $_{quote}) {
		push @args, method => $_{quote};
	}
	
	if ($obj->signal(with => $signal, @args)) {
		$session->write("Signal sent.");
	}
	else {
		fail "Failed to send signal.";
	}
}
