[dev] [sdhcp] [PATCH 1/2] Only fork once

From: Michael Forney <mforney_AT_mforney.org>
Date: Mon, 27 Apr 2015 01:00:02 +0000

---
 sdhcp.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/sdhcp.c b/sdhcp.c
index aa3cef2..9ff9baf 100644
--- a/sdhcp.c
+++ b/sdhcp.c
_AT_@ -339,6 +339,8 @@ acceptlease(void)
 static void
 run(void)
 {
+	int forked = 0;
+
 #if 0
 InitReboot:
 	/* send DHCPrequest to old server */
_AT_@ -390,8 +392,11 @@ Requesting:
 	}
 Bound:
 	fputs("Congrats! You should be on the 'net.\n", stdout);
-	if(fork())
-		exit(EXIT_SUCCESS);
+	if(!forked) {
+		if(fork())
+			exit(EXIT_SUCCESS);
+		forked = 1;
+	}
 	switch (dhcprecv()) {
 	case DHCPoffer:
 	case DHCPack:
-- 
2.1.3.1.g339ec9c
Received on Mon Apr 27 2015 - 03:00:02 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 27 2015 - 03:12:08 CEST