[klibc] [PATCH]: Exiting -1 if dhcp client failed
Erwan Velu
erwanaliasr1 at gmail.com
Tue Aug 24 12:05:44 PDT 2010
Hey,
I was scripting in klibc and wanted to make an action when the dhcp client
failed at grabing an IP after the defined timeout.
I found that klibc always exit 0 which isn't that convenient .
I wrote a stupid patch that solve this issue.
Cheers,
Erwan
From: Erwan Velu <erwan.velu at zodiacaerospace.com>
Date: Tue, 24 Aug 2010 10:00:23 +0000 (+0200)
Subject: Exiting -1 if ipconfig timeout
X-Git-Url:
http://gitweb.ife-sit.info/?p=zodiac-pkg%2Fklibc.git;a=commitdiff_plain;h=6c4c52e6f64412fce844d0198643ccecc641f1b5
Exiting -1 if ipconfig timeout
When timeouting while getting up a dhclient answer, let's returning -1
instead of 0
---
diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c
index f00041b..888fdeb 100644
--- a/usr/kinit/ipconfig/main.c
+++ b/usr/kinit/ipconfig/main.c
-334,6 +334,7 @@ static int loop(void)
int nr = 0;
struct timeval now, prev;
time_t start;
+ int return_code=0;
pkt_fd = packet_open();
if (pkt_fd == -1) {
-396,6 +397,7 @@ static int loop(void)
now.tv_sec - start >= loop_timeout) {
printf("IP-Config: no response after %d "
"secs - giving up\n", loop_timeout);
+ return_code=-1;
goto bail;
}
-410,7 +412,7 @@ static int loop(void)
bail:
packet_close();
- return 0;
+ return return_code;
}
static int add_one_dev(struct netdev *dev)
-724,7 +726,7 @@ int ipconfig_main(int argc, char *argv[])
{
struct netdev *dev;
int c, port;
- int err;
+ int err=0;
/* If progname is set we're invoked from another program */
if (!progname) {
-740,6 +742,9 @@ int ipconfig_main(int argc, char *argv[])
/* Default vendor identifier */
set_vendor_identifier("Linux ipconfig");
+ /* Reseting the exit code to 0*/
+ err=0;
+
do {
c = getopt(argc, argv, "c:d:i:onp:t:");
if (c == EOF)
-802,8 +807,8 @@ int ipconfig_main(int argc, char *argv[])
"dest to %d\n",
cfg_local_port, cfg_remote_port);
}
- loop();
+ err=loop();
}
- return 0;
+ return err;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.zytor.com/pipermail/klibc/attachments/20100824/2d8e42eb/attachment.html>
More information about the klibc
mailing list