On Thursday 26 June 2008 16:17, Pascal Bellard wrote:
> Hello,
> 
> Udhcpc: do not hang when network is down
> http://hg.slitaz.org/wok/raw-file/be0892d9efd5/busybox/stuff/busybox-1.11.0-dhcpc.u

Actually, I want to "hang" (actually, retry forever) when network is down.
I run udhcpc indefinitely, and I don't want it to bail out just because
e.g. some other async script failed to up the interface in time.

You obvious want it ot exit. This already works!

Look at the code again:

                                if (packet_num < discover_retries) {
                                        if (packet_num == 0)
                                                xid = random_xid();

                                        send_discover(xid, requested_ip); /* 
broadcast */

                                        timeout = discover_timeout;
                                        packet_num++;
                                        continue;
                                }

we are here if packet_num >= discover_retries. now...

                                udhcp_run_script(NULL, "leasefail");
                                if (opt & OPT_b) { /* background if no lease */
                                        bb_info_msg("No lease, forking to 
background");
                                        client_background();
                                        /* do not background again! */
                                        opt = ((opt & ~OPT_b) | OPT_f);
                                } else
                                if (opt & OPT_n) { /* abort if no lease */
                                        bb_info_msg("No lease, failing");
                                        retval = 1;
                                        goto ret;
                                }

Yes! this is it! if you want udhcpc to exit, give it -n option.

                                /* wait before trying again */
                                timeout = tryagain_timeout;
                                packet_num = 0;
                                continue;

Am I missing something?
--
vda
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to