summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2020-08-16 01:08:55 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2020-08-16 22:50:14 +0200
commit0a01d20171a2c39f0d1fb8455e9b2f6252471efc (patch)
tree9fa2c412abc5fb48b2e0d6ca5bfa340fa4012bb0
parent8086e4175d6af3cc3b17840a3ffa1ea03964675d (diff)
add foreground option
-rw-r--r--gre.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gre.c b/gre.c
index 7ec4acd..d66fd36 100644
--- a/gre.c
+++ b/gre.c
@@ -45,6 +45,7 @@ static struct sockaddr_storage remote;
static size_t remote_len;
static short type = IFF_TUN;
static uint8_t mac[6];
+static int foreground;
uint8_t buf[65536];
@@ -67,17 +68,21 @@ int main(int argc, char **argv)
{
int option_index = 0;
static struct option long_options[] = {
+ {"foreground", no_argument, 0, 'f' },
{"tun", no_argument, 0, 'n' },
{"tap", no_argument, 0, 'p' },
{0, 0, 0, 0 }
};
- char c = getopt_long(argc, argv, "np",
+ char c = getopt_long(argc, argv, "fnp",
long_options, &option_index);
if (c == -1)
break;
switch (c) {
+ case 'f':
+ foreground = 1;
+ break;
case 'n':
printf("tun\n");
type = IFF_TUN;
@@ -143,7 +148,9 @@ int main(int argc, char **argv)
setnonblock(sock);
setnonblock(tun);
runas("nobody");
- daemonize();
+
+ if (!foreground)
+ daemonize();
int maxfd = (tun > sock ? tun : sock) + 1;
while (1)