net: ping: return an error exit code when connection fails
PATCH 1/1 net: ping: return an error exit code when connection fails
Hi,
ping command does not always returns 1 as exit code when connection to host fails. In particular it returns the exit code of the previous run.
This patch fixes this issue.
--- net/ping.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/ping.c +3 -3
@@ -67,6 +67,9 @@ static int do_ping(int argc, char *argv[])return 1 ; } + ping_state =PING_STATE_INIT ; + ping_sequence_number =0 ; + ping_con =net_icmp_new (net_ping_ip, ping_handler,NULL );if (IS_ERR (ping_con)) { ret =PTR_ERR (ping_con);
@@ -78,9 +81,6 @@ static int do_ping(int argc, char *argv[])if (ret) goto out_unreg; - ping_state =PING_STATE_INIT ; - ping_sequence_number =0 ; -while (ping_state ==PING_STATE_INIT ) {if (ctrlc ()) { ret = -EINTR ;
Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Il 2015-03-16 16:02 Mirko Damiani ha scritto:
Quoted 6 lines
Hi,
ping command does not always returns 1 as exit code when connection to host fails.
In particular it returns the exit code of the previous run. This patch fixes this issue.
Sorry, the same patch with proper tabulation characters.
--- net/ping.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/ping.c +3 -3
@@ -67,6 +67,9 @@ static int do_ping(int argc, char *argv[])return 1 ; } + ping_state =PING_STATE_INIT ; + ping_sequence_number =0 ; + ping_con =net_icmp_new (net_ping_ip, ping_handler,NULL );if (IS_ERR (ping_con)) { ret =PTR_ERR (ping_con);
@@ -78,9 +81,6 @@ static int do_ping(int argc, char *argv[])if (ret) goto out_unreg; - ping_state =PING_STATE_INIT ; - ping_sequence_number =0 ; -while (ping_state ==PING_STATE_INIT ) {if (ctrlc ()) { ret = -EINTR ;
Signature · 6 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Mirko,
Quoted 9 lines · mirko
Il 2015-03-16 16:02 Mirko Damiani ha scritto:
Quoted 6 lines
Hi,
ping command does not always returns 1 as exit code when connection to host fails.
In particular it returns the exit code of the previous run. This patch fixes this issue.Sorry, the same patch with proper tabulation characters.
I can confirm that this patch now has tabs instead of spaces, but it still does not apply because there are some spaces in the context which shouldn't be there. Anyway, applied it manually, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox