diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-08-16 01:08:55 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-08-16 22:50:14 +0200 |
commit | 0a01d20171a2c39f0d1fb8455e9b2f6252471efc (patch) | |
tree | 9fa2c412abc5fb48b2e0d6ca5bfa340fa4012bb0 | |
parent | 8086e4175d6af3cc3b17840a3ffa1ea03964675d (diff) |
add foreground option
-rw-r--r-- | gre.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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) |