diff options
author | Erwan Velu <erwan.velu@zodiacaerospace.com> | 2010-08-24 10:00:23 +0200 |
---|---|---|
committer | maximilian attems <max@stro.at> | 2010-08-25 20:29:05 +0200 |
commit | 2028152b7af7700e01bd3300c3f7d903afbf34de (patch) | |
tree | 9766e487faf499b24fe83c868e91bdc1942054e2 | |
parent | 8a9b80da8295a8b21a4de44840a36aab72654a5b (diff) | |
download | klibc-2028152b7af7700e01bd3300c3f7d903afbf34de.tar.gz |
[klibc] ipconfig: non zero exit on timeout
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 .
Belows patch fixes the issue.
[ small coding style changes - maks]
Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r-- | usr/kinit/ipconfig/main.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c index b0141287e1e12..b392e6aea0e0d 100644 --- a/usr/kinit/ipconfig/main.c +++ b/usr/kinit/ipconfig/main.c @@ -331,7 +331,7 @@ static int loop(void) struct pollfd fds[NR_FDS]; struct state *s; int pkt_fd; - int nr = 0; + int nr = 0, rc = 0; struct timeval now, prev; time_t start; @@ -396,6 +396,7 @@ static int loop(void) now.tv_sec - start >= loop_timeout) { printf("IP-Config: no response after %d " "secs - giving up\n", loop_timeout); + rc = -1; goto bail; } @@ -410,7 +411,7 @@ static int loop(void) bail: packet_close(); - return 0; + return rc; } static int add_one_dev(struct netdev *dev) @@ -724,7 +725,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) { @@ -802,8 +803,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; } |