CP-34834: Add foreground mode to td-rated

From: Mark Syms <mark.syms@citrix.com>

Signed-off-by: Mark Syms <mark.syms@citrix.com>

diff --git a/drivers/td-rated.c b/drivers/td-rated.c
index 3b89f41..8d0b053 100644
--- a/drivers/td-rated.c
+++ b/drivers/td-rated.c
@@ -68,6 +68,8 @@ rlb_log(int prio, const char *fmt, ...)
 
 static int debug = 0;
 
+static bool foreground = false;
+
 #define DBG(_l, _f, _a...) if (debug >= _l) { rlb_log(LOG_DEBUG, _f, ##_a); }
 #define INFO(_f, _a...)    rlb_log(LOG_INFO, _f, ##_a)
 #define WARN(_f, _a...)    rlb_log(LOG_WARNING, "WARNING: " _f ", in %s:%d", \
@@ -1650,7 +1652,7 @@ main(int argc, char **argv)
 		};
 		int c;
 
-		c = getopt_long(argc, argv, "ht:D:", longopts, NULL);
+		c = getopt_long(argc, argv, "hft:D:", longopts, NULL);
 		if (c < 0)
 			break;
 
@@ -1665,6 +1667,11 @@ main(int argc, char **argv)
 
 		case 'D':
 			debug = strtoul(optarg, NULL, 0);
+			foreground = true;
+			break;
+
+		case 'f':
+			foreground = true;
 			break;
 
 		case '?':
@@ -1705,11 +1712,13 @@ main(int argc, char **argv)
 		goto fail;
 	}
 
-	if (!debug) {
+	if (!foreground) {
 		err = daemon(0, 0);
 		if (err)
 			goto fail;
+	}
 
+	if (!debug) {
 		stdin = stdout = stderr = NULL;
 		rlb_openlog(prog, LOG_DAEMON);
 	}
