[BusyBox] trouble with udhcp

Ulrich Marx um at emlix.com
Thu Nov 13 08:04:57 UTC 2003


hello

i had some trouble with the filedescriptor in udhcp.
Two things happened on my device:
1.) broken or not connected cable (no dhcp-server)
2.) daemonizing (starting with option -b)

i got a filedescriptor fd=0 from function raw_socket, 
after daemonizing (daemon call) the fd is closed. 
Client can't recieve data's anymore. 

i fixed this problem (like pidfile handling):

diff -urN busybox.orig/networking/udhcp/socket.c 
busybox/networking/udhcp/socket.c
--- busybox.orig/networking/udhcp/socket.c      2003-08-29 17:19:44.000000000 
+0200
+++ busybox/networking/udhcp/socket.c   2003-11-12 11:14:08.000000000 +0100
@@ -141,7 +141,9 @@
                DEBUG(LOG_ERR, "socket call failed: %m");
                return -1;
        }
-
+
+       while (fd >= 0 && fd < 3) fd = dup(fd); /* don't let daemon close it 
*/
+
        sock.sll_family = AF_PACKET;
        sock.sll_protocol = htons(ETH_P_IP);
        sock.sll_ifindex = ifindex;





ulrich



-- 

--
dipl. ing. ulrich marx, emlix gmbh, http://www.emlix.com, mailto:um at emlix.com
fon +49 551 37000-37, fax -38, keplerstrasse 7, 37085 goettingen, germany

emlix - your embedded linux partner




More information about the busybox mailing list