die $@;
}
+$0 = "mythtv-status - parent";
+
# Some sane defaults.
$c->{'host'} ||= "localhost";
$c->{'port'} ||= "6544";
eval {
local $SIG{ALRM} = sub { die "alarm\n" };
- alarm(30);
+ alarm(10);
$content_type = <CHILD>;
while (<CHILD>) {
$status .= $_;
alarm(0);
};
- # The child didn't get back to us in time, kill them off.
+ # The child didn't get back to us in time, kill them off
+ # and forget what they sent us.
if ($@) {
+ $status = undef;
my $result;
+ warn "Our child has stopped talking to us, kill it off.\n";
do {
kill 9, $pid;
$result = waitpid($pid, WNOHANG);
} while $result > 0;
+
+ die "Unknown error during retrieval of status from the MythTV backend.\n";
}
$| = 0;
return ($content_type, $status);
} else {
# child
+ $0 = "mythtv-status - child";
my $ua = LWP::UserAgent->new;
$ua->timeout(30);
$ua->env_proxy;
die "Sorry, failed to fetch $url: Connection to MythTV timed out.\n"
unless defined $response;
- # If we get a page doesn't exist, then just ignore it, we need to fetch
- # the status page from a few different locations.
+ # If we get a page doesn't exist, then just ignore it, we need to try
+ # fetching the status page from a few different locations.
if ($response->code == 404) {
exit 1;
}