]> git.gsnw.org Git - fping.git/commitdiff
Exit code should be 2 when the hostname can't be resolved (fixes #98)
authorDavid Schweikert <david@schweikert.ch>
Fri, 5 Aug 2016 10:02:37 +0000 (12:02 +0200)
committerDavid Schweikert <david@schweikert.ch>
Fri, 5 Aug 2016 10:02:37 +0000 (12:02 +0200)
ChangeLog
ci/test-13-unknown-host.pl
src/fping.c

index d9d90fc067bfe8a78d9dc54f75245077702da4d9..bcf42638057890089f5bf481a1fd96ae198e5283 100644 (file)
--- 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  <david@schweikert.ch>
   * Version 3.13
   * (bugfix) Fix ICMP errors sometimes causing crashes with fping >= 3.11
index 9ee50212767e989ffacda14632cbab91dfd1488d..8094c05e80fed591a4e45b5fdbb5414196b2325d 100755 (executable)
@@ -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)});
 }
index a7af5ed9a366b64885c7bcd1925c3f142e4c418c..02545b1931f3c5db235e2f93adbc9756322964e5 100644 (file)
@@ -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);