In Net::DNS 1.42 $ns->main_loop no longer loops. Use current methods
for starting the server, wait for SIGTERM then cleanup child processes
using $ns->stop_server(), then remove the pid file.
(cherry picked from commit
c2c59dea60135ac2835c52e8d9ecaf76bffeb634)
print $pidf "$$\n" or die "cannot write pid file: $!";
$pidf->close or die "cannot close pid file: $!";
sub rmpid { unlink "ans.pid"; exit 1; };
+sub term { };
$SIG{INT} = \&rmpid;
-$SIG{TERM} = \&rmpid;
+if ($Net::DNS::VERSION > 1.41) {
+ $SIG{TERM} = \&term;
+} else {
+ $SIG{TERM} = \&rmpid;
+}
my $localaddr = "10.53.0.3";
Verbose => $verbose,
);
-$ns->main_loop;
+if ($Net::DNS::VERSION >= 1.42) {
+ $ns->start_server();
+ select(undef, undef, undef, undef);
+ $ns->stop_server();
+ unlink "ans.pid";
+} else {
+ $ns->main_loop;
+}
print $pidf "$$\n" or die "cannot write pid file: $!";
$pidf->close or die "cannot close pid file: $!";
sub rmpid { unlink "ans.pid"; exit 1; };
+sub term { };
$SIG{INT} = \&rmpid;
-$SIG{TERM} = \&rmpid;
+if ($Net::DNS::VERSION >= 1.42) {
+ $SIG{TERM} = \&term;
+} else {
+ $SIG{TERM} = \&rmpid;
+}
my $count = 0;
Verbose => $verbose,
);
-$ns->main_loop;
+if ($Net::DNS::VERSION >= 1.42) {
+ $ns->start_server();
+ select(undef, undef, undef, undef);
+ $ns->stop_server();
+ unlink "ans.pid";
+} else {
+ $ns->main_loop;
+}