[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>
diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c
index b014128..b392e6a 100644
--- a/usr/kinit/ipconfig/main.c
+++ b/usr/kinit/ipconfig/main.c
@@ -331,7 +331,7 @@
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 @@
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 @@
bail:
packet_close();
- return 0;
+ return rc;
}
static int add_one_dev(struct netdev *dev)
@@ -724,7 +725,7 @@
{
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 @@
"dest to %d\n",
cfg_local_port, cfg_remote_port);
}
- loop();
+ err = loop();
}
- return 0;
+ return err;
}