#!/usr/bin/perl
#
# An interesting command to run under k5start or krenew to perform various
# tests.  It takes on the command-line a file into which to write, and into
# that file, it puts its PID, its current working directory, and its ticket
# cache.  When it gets a HUP or INT signal, it writes into that file.  When it
# gets a TERM signal, it writes into that file and exits.

use Cwd;

$| = 1;
$SIG{HUP} = sub { print OUT "got SIGHUP\n" };
$SIG{INT} = sub { print OUT "got SIGINT\n" };
$SIG{QUIT} = sub { print OUT "got SIGQUIT\n"; exit 0 };
$SIG{TERM} = sub { print OUT "got SIGTERM\n"; exit 0 };
print "Starting\n";
my $file = shift;
open (OUT, '>', $file) or die "Cannot write to $file: $!\n";
OUT->autoflush (1);
print OUT "$$\n", getcwd, "\n", $ENV{KRB5CCNAME}, "\n";
sleep 1000 while 1;
