Skip to content

Commit

Permalink
Allow running fping --help even when raw socket can't be opened, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
schweikert committed Jul 29, 2018
1 parent b2d3517 commit df7a819
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ fping 4.1 (UNRELEASED)

- Fix problem when socket fd is 0 (#125, thanks Ramón Novoa!)
- Fix running on servers with disabled IPv6 (#118, thanks Simon Matter)
- Allow running "fping -h" or "--help" even when raw socket can't be opened (#131, thanks @teto)

fping 4.0 (2017-04-23)
======================
Expand Down
6 changes: 6 additions & 0 deletions src/fping.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ int main(int argc, char** argv)
HOST_ENTRY* cursor;
struct optparse optparse_state;

/* pre-parse -h/--help, so that we also can output help information
* without trying to open the socket, which might fail */
if(argc == 2 && ( strcmp(argv[1],"-h")==0 || strcmp(argv[1],"--help")==0 )) {
usage(0);
}

socket4 = open_ping_socket_ipv4(ping_data_size);
#ifdef IPV6
socket6 = open_ping_socket_ipv6(ping_data_size);
Expand Down

0 comments on commit df7a819

Please sign in to comment.