From 6086de1746be753ac2b720fd7eca3e7da31ad2cc Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 27 May 2014 01:27:10 +0200 Subject: daemon optional --- ldadp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ldadp.c b/ldadp.c index 2cfbed0..00a3f05 100644 --- a/ldadp.c +++ b/ldadp.c @@ -18,11 +18,17 @@ static void loadConfig(char *file); int main(int argc, char **argv) { + BOOL isdaemon = TRUE; if (argc < 2) { printf("Nö\n"); exit(1); } signal(SIGPIPE, SIG_IGN); + if (strcmp(argv[1], "-n") == 0 && argc > 2) { + isdaemon = FALSE; + argv++; + argc--; + } loadConfig(argv[1]); proxy_init(); char listen_addr[4] = {0, 0, 0, 0}; @@ -40,7 +46,7 @@ int main(int argc, char **argv) // Init AD uplinks server_initServers(); // Daeaeaemon - if (daemon(1, 0) == -1) bail("daemon() failed."); + if (isdaemon && daemon(1, 0) == -1) bail("daemon() failed."); // Do the mainloop for (;;) { if (ePoll_wait(-1) == -1) bail("ePoll wait failed."); -- cgit v1.2.3-55-g7522