From a37399ede9bbf48cc6a5c3633aa13ddc0cd371a7 Mon Sep 17 00:00:00 2001 From: David Schweikert Date: Fri, 5 Aug 2016 12:02:37 +0200 Subject: [PATCH] Exit code should be 2 when the hostname can't be resolved (fixes #98) --- ChangeLog | 4 ++++ ci/test-13-unknown-host.pl | 4 ++-- src/fping.c | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d9d90fc..bcf4263 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +UNRELEASED + * (bugfix) Exit code should be 2 when the hostname can't be resolved + (fixes #98, reported by @green-fox) + 2015-10-21 David Schweikert * Version 3.13 * (bugfix) Fix ICMP errors sometimes causing crashes with fping >= 3.11 diff --git a/ci/test-13-unknown-host.pl b/ci/test-13-unknown-host.pl index 9ee5021..8094c05 100755 --- a/ci/test-13-unknown-host.pl +++ b/ci/test-13-unknown-host.pl @@ -5,7 +5,7 @@ use Test::Command tests => 6; # fping { my $cmd = Test::Command->new(cmd => "fping nosuchname.example.com"); -$cmd->exit_is_num(1); +$cmd->exit_is_num(2); $cmd->stdout_is_eq(""); $cmd->stderr_like(qr{^nosuchname\.example\.com: .*not (known|found)}); } @@ -13,7 +13,7 @@ $cmd->stderr_like(qr{^nosuchname\.example\.com: .*not (known|found)}); # fping6 { my $cmd = Test::Command->new(cmd => "fping6 nosuchname.example.com"); -$cmd->exit_is_num(1); +$cmd->exit_is_num(2); $cmd->stdout_is_eq(""); $cmd->stderr_like(qr{^nosuchname\.example\.com: .*not (known|found)}); } diff --git a/src/fping.c b/src/fping.c index a7af5ed..02545b1 100644 --- a/src/fping.c +++ b/src/fping.c @@ -777,8 +777,9 @@ int main( int argc, char **argv ) usage(1); } - if( !num_hosts ) - exit(1); + if(!num_hosts) { + exit(num_noaddress ? 2 : 1); + } if(src_addr_present) { socket_set_src_addr(s, src_addr); -- 2.43.0