Only fork once - sdhcp - simple dhcp client
(HTM) git clone git://git.codemadness.org/sdhcp
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 4716991b7cf1cf79d3ddf27b16690ccb37e863b7
(DIR) parent 462f43e6073a740dfb71e720ace9d7f041e36b36
(HTM) Author: Michael Forney <mforney@mforney.org>
Date: Mon, 27 Apr 2015 01:00:02 +0000
Only fork once
Diffstat:
M sdhcp.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/sdhcp.c b/sdhcp.c
@@ -339,6 +339,8 @@ acceptlease(void)
static void
run(void)
{
+ int forked = 0;
+
#if 0
InitReboot:
/* send DHCPrequest to old server */
@@ -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: