[BusyBox-cvs] busybox/networking/udhcp socket.c,1.3,1.4

Erik Andersen andersen at busybox.net
Fri Nov 14 03:00:11 UTC 2003


Update of /var/cvs/busybox/networking/udhcp
In directory winder:/tmp/cvs-serv32370/networking/udhcp

Modified Files:
	socket.c 
Log Message:
Ulrich Marx writes:

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):



Index: socket.c
===================================================================
RCS file: /var/cvs/busybox/networking/udhcp/socket.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- socket.c	29 Aug 2003 15:19:44 -0000	1.3
+++ socket.c	14 Nov 2003 03:00:04 -0000	1.4
@@ -141,6 +141,8 @@
 		DEBUG(LOG_ERR, "socket call failed: %m");
 		return -1;
 	}
+
+	while (fd >= 0 && fd < 3) fd = dup(fd); /* don't let daemon close fds on us */
 	
 	sock.sll_family = AF_PACKET;
 	sock.sll_protocol = htons(ETH_P_IP);




More information about the busybox-cvs mailing list