sdhcp

simple dhcp client
git clone git://git.2f30.org/sdhcp.git
Log | Files | Refs | LICENSE

commit 6453b6d68c6452bb0731b3250e308d4e6750dbec
parent 4716991b7cf1cf79d3ddf27b16690ccb37e863b7
Author: Michael Forney <mforney@mforney.org>
Date:   Mon Apr 27 01:00:03 +0000

Add flag to run in foreground

Diffstat:
sdhcp.1 | 3+++
sdhcp.c | 8++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/sdhcp.1 b/sdhcp.1 @@ -28,6 +28,9 @@ don't change interface information such as an IP address. .TP .B "\-e program" run program. Variables will be set, see VARIABLES. +.TP +.B \-f +run in foreground. .SH VARIABLES .LP The following variables are set: diff --git a/sdhcp.c b/sdhcp.c @@ -97,6 +97,7 @@ static unsigned long t1; static int dflag = 1; /* change DNS in /etc/resolv.conf ? */ static int iflag = 1; /* set IP ? */ +static int fflag = 0; /* run in foreground */ #define IP(a,b,c,d) (unsigned char[4]){a,b,c,d} @@ -392,7 +393,7 @@ Requesting: } Bound: fputs("Congrats! You should be on the 'net.\n", stdout); - if(!forked) { + if(!fflag && !forked) { if(fork()) exit(EXIT_SUCCESS); forked = 1; @@ -439,7 +440,7 @@ static void cleanexit(int unused) { static void usage(void) { - eprintf("usage: sdhcp [-i] [-d] [-e program] [ifname] [clientid]\n"); + eprintf("usage: sdhcp [-i] [-d] [-f] [-e program] [ifname] [clientid]\n"); } int @@ -460,6 +461,9 @@ main(int argc, char *argv[]) case 'd': /* don't update DNS in/etc/resolv.conf */ dflag = 0; break; + case 'f': /* run in foreground */ + fflag = 1; + break; default: usage(); break;